use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class BaseActionWizard method getUsers.
/**
* @return the List of users in the system wrapped in SelectItem objects
*/
public List<SelectItem> getUsers() {
if (this.users == null) {
List<Node> userNodes = Repository.getUsers(FacesContext.getCurrentInstance(), this.getNodeService(), this.getPersonService());
this.users = new ArrayList<SelectItem>();
for (Node user : userNodes) {
String email = (String) user.getProperties().get("email");
if (email != null && email.length() > 0) {
this.users.add(new SelectItem(email, (String) user.getProperties().get("fullName")));
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.users, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
return this.users;
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class EditCategoryDialog method init.
@Override
public void init(Map<String, String> parameters) {
this.isFinished = false;
this.categoryFlag = false;
// retrieve parameters
categoryRef = parameters.get(CategoriesDialog.PARAM_CATEGORY_REF);
// make sure nodeRef was supplied
ParameterCheck.mandatoryString(CategoriesDialog.PARAM_CATEGORY_REF, categoryRef);
// create the node
this.category = new Node(new NodeRef(categoryRef));
setActionCategory(category);
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class EditNodeCategoriesDialog method init.
// ------------------------------------------------------------------------------
// Dialog implementation
@Override
public void init(Map<String, String> parameters) {
super.init(parameters);
// reset variables
this.categories = null;
this.addedCategory = null;
// retrieve parameters
String nodeRef = parameters.get("nodeRef");
// make sure nodeRef was supplied
ParameterCheck.mandatoryString("nodeRef", nodeRef);
// create the node
this.node = new Node(new NodeRef(nodeRef));
// determine description for dialog
FacesContext context = FacesContext.getCurrentInstance();
if (getDictionaryService().isSubClass(this.node.getType(), ContentModel.TYPE_FOLDER)) {
this.description = Application.getMessage(context, "editcategory_space_description");
} else {
this.description = Application.getMessage(context, "editcategory_description");
}
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class CCCheckoutFileDialog method checkoutFile.
/**
* Action called upon completion of the Check Out file page
*/
public String checkoutFile(FacesContext context, String outcome) {
boolean checkoutSuccessful = false;
final Node node = property.getDocument();
if (node != null) {
try {
if (logger.isDebugEnabled())
logger.debug("Trying to checkout content node Id: " + node.getId());
// checkout the node content to create a working copy
if (logger.isDebugEnabled()) {
logger.debug("Checkout copy location: " + property.getCopyLocation());
logger.debug("Selected Space Id: " + property.getSelectedSpaceId());
}
NodeRef workingCopyRef = null;
if (property.getCopyLocation().equals(CCProperties.COPYLOCATION_OTHER) && property.getSelectedSpaceId() != null) {
// checkout to a arbituary parent Space
NodeRef destRef = property.getSelectedSpaceId();
ChildAssociationRef childAssocRef = getNodeService().getPrimaryParent(destRef);
workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef(), destRef, ContentModel.ASSOC_CONTAINS, childAssocRef.getQName());
} else {
// checkout the content to the current space
workingCopyRef = property.getVersionOperationsService().checkout(node.getNodeRef());
// in the resources panel in the manage task dialog
if (property.isWorkflowAction() && property.getWorkflowTaskId() != null && (property.getWorkflowTaskId().equals("null") == false)) {
WorkflowTask task = property.getWorkflowService().getTaskById(property.getWorkflowTaskId());
if (task != null) {
NodeRef workflowPackage = (NodeRef) task.properties.get(WorkflowModel.ASSOC_PACKAGE);
if (workflowPackage != null) {
getNodeService().addChild(workflowPackage, workingCopyRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName((String) getNodeService().getProperty(workingCopyRef, ContentModel.PROP_NAME))));
if (logger.isDebugEnabled())
logger.debug("Added working copy to workflow package: " + workflowPackage);
}
}
}
}
// set the working copy Node instance
Node workingCopy = new Node(workingCopyRef);
property.setWorkingDocument(workingCopy);
// create content URL to the content download servlet with ID
// and expected filename
// the myfile part will be ignored by the servlet but gives the
// browser a hint
String url = DownloadContentServlet.generateDownloadURL(workingCopyRef, workingCopy.getName());
workingCopy.getProperties().put("url", url);
workingCopy.getProperties().put("fileType32", FileTypeImageUtils.getFileTypeImage(workingCopy.getName(), false));
// mark as successful
checkoutSuccessful = true;
} catch (Throwable err) {
Utils.addErrorMessage(Application.getMessage(context, MSG_ERROR_CHECKOUT) + err.getMessage(), err);
ReportedException.throwIfNecessary(err);
}
} else {
logger.warn("WARNING: checkoutFile called without a current Document!");
}
// determine which page to show next if the checkout was successful.
if (checkoutSuccessful) {
// already disappeared!
if (getNodeService().exists(property.getWorkingDocument().getNodeRef())) {
// go to the page that allows the user to download the content
// for editing
// "checkoutFileLink";
outcome = "dialog:checkoutFileLink";
// //checkout-file-link.jsp
// currentAction = Action.CHECKOUT_FILE_LINK;
} else {
// show a page telling the user that the content has already
// been checked in
// "workingCopyMissing";
outcome = "dialog:workingCopyMissing";
// //
// working-copy-missing.jsp
// currentAction = Action.WORKING_COPY_MISSING;
}
}
return outcome;
}
use of org.alfresco.web.bean.repository.Node in project acs-community-packaging by Alfresco.
the class EditContentPropertiesCommand method execute.
/**
* @see org.alfresco.web.app.servlet.command.Command#execute(org.alfresco.service.ServiceRegistry, java.util.Map)
*/
public Object execute(ServiceRegistry serviceRegistry, Map<String, Object> properties) {
ServletContext sc = (ServletContext) properties.get(PROP_SERVLETCONTEXT);
ServletRequest req = (ServletRequest) properties.get(PROP_REQUEST);
ServletResponse res = (ServletResponse) properties.get(PROP_RESPONSE);
FacesContext fc = FacesHelper.getFacesContext(req, res, sc, "/jsp/close.jsp");
BrowseBean browseBean = (BrowseBean) FacesHelper.getManagedBean(fc, BrowseBean.BEAN_NAME);
// setup context from url args in properties map
String strNodeRef = (String) properties.get(PROP_NODEREF);
ParameterCheck.mandatoryString(PROP_NODEREF, strNodeRef);
browseBean.setDocument(new Node(new NodeRef(strNodeRef)));
NavigationHandler navigationHandler = fc.getApplication().getNavigationHandler();
navigationHandler.handleNavigation(fc, null, "dialog:editContentProperties");
String viewId = fc.getViewRoot().getViewId();
try {
sc.getRequestDispatcher(BaseServlet.FACES_SERVLET + viewId).forward(req, res);
} catch (Exception e) {
throw new AlfrescoRuntimeException("Unable to forward to viewId: " + viewId, e);
}
return null;
}
Aggregations