use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.
the class BaseInviteUsersWizard method getEmailTemplates.
/**
* @return Returns the list of email templates for user notification
*/
public List<SelectItem> getEmailTemplates() {
List<SelectItem> wrappers = null;
try {
FacesContext fc = FacesContext.getCurrentInstance();
NodeRef rootNodeRef = this.getNodeService().getRootNode(Repository.getStoreRef());
NamespaceService resolver = Repository.getServiceRegistry(fc).getNamespaceService();
List<NodeRef> results = this.getSearchService().selectNodes(rootNodeRef, getEmailTemplateXPath(), null, resolver, false);
wrappers = new ArrayList<SelectItem>(results.size() + 1);
if (results.size() != 0) {
DictionaryService dd = Repository.getServiceRegistry(fc).getDictionaryService();
for (NodeRef ref : results) {
if (this.getNodeService().exists(ref) == true) {
Node childNode = new Node(ref);
if (dd.isSubClass(childNode.getType(), ContentModel.TYPE_CONTENT)) {
wrappers.add(new SelectItem(childNode.getId(), childNode.getName()));
}
}
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(wrappers, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
} catch (AccessDeniedException accessErr) {
// ignore the result if we cannot access the root
}
// add an entry (at the start) to instruct the user to select an item
if (wrappers == null) {
wrappers = new ArrayList<SelectItem>(1);
}
wrappers.add(0, new SelectItem("none", Application.getMessage(FacesContext.getCurrentInstance(), "select_a_template")));
return wrappers;
}
use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.
the class AdvancedSearchDialog method getFolderTypes.
/**
* @return Returns a list of folder object types to allow the user to select from
*/
public List<SelectItem> getFolderTypes() {
if ((properties.getFolderTypes() == null) || (Application.isDynamicConfig(FacesContext.getCurrentInstance()))) {
FacesContext context = FacesContext.getCurrentInstance();
DictionaryService dictionaryService = Repository.getServiceRegistry(context).getDictionaryService();
// add the well known cm:folder object type by default
properties.setFolderTypes(new ArrayList<SelectItem>(5));
properties.getFolderTypes().add(new SelectItem(ContentModel.TYPE_FOLDER.toString(), dictionaryService.getType(ContentModel.TYPE_FOLDER).getTitle(dictionaryService)));
// add any configured folder sub-types to the list
List<String> types = getSearchConfig().getFolderTypes();
if (types != null) {
for (String type : types) {
QName idQName = Repository.resolveToQName(type);
if (idQName != null) {
TypeDefinition typeDef = dictionaryService.getType(idQName);
if (typeDef != null && dictionaryService.isSubClass(typeDef.getName(), ContentModel.TYPE_FOLDER)) {
// try and get label from the dictionary
String label = typeDef.getTitle(dictionaryService);
// else just use the localname
if (label == null) {
label = idQName.getLocalName();
}
properties.getFolderTypes().add(new SelectItem(idQName.toString(), label));
}
}
}
}
}
return properties.getFolderTypes();
}
use of org.alfresco.service.cmr.dictionary.DictionaryService in project acs-community-packaging by Alfresco.
the class UserShortcutsBean method click.
/**
* Action handler bound to the user shortcuts Shelf component called when a node is clicked
*/
public void click(ActionEvent event) {
// work out which node was clicked from the event data
UIShortcutsShelfItem.ShortcutEvent shortcutEvent = (UIShortcutsShelfItem.ShortcutEvent) event;
Node selectedNode = getShortcuts().get(shortcutEvent.Index);
try {
if (getPermissionService().hasPermission(selectedNode.getNodeRef(), PermissionService.READ) == AccessStatus.ALLOWED) {
if (getNodeService().exists(selectedNode.getNodeRef()) == false) {
throw new InvalidNodeRefException(selectedNode.getNodeRef());
}
DictionaryService dd = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getDictionaryService();
if (dd.isSubClass(selectedNode.getType(), ContentModel.TYPE_FOLDER)) {
// then navigate to the appropriate node in UI
// use browse bean functionality for this as it will update the breadcrumb for us
this.browseBean.updateUILocation(selectedNode.getNodeRef());
} else if (dd.isSubClass(selectedNode.getType(), ContentModel.TYPE_CONTENT)) {
// view details for document
this.browseBean.setupContentAction(selectedNode.getId(), true);
FacesContext fc = FacesContext.getCurrentInstance();
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, "dialog:showDocDetails");
}
} else {
Utils.addErrorMessage(Application.getMessage(FacesContext.getCurrentInstance(), "error_shortcut_permissions"));
}
} catch (InvalidNodeRefException refErr) {
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(FacesContext.getCurrentInstance(), Repository.ERROR_NODEREF), new Object[] { selectedNode.getId() }));
// remove item from the shortcut list
UserTransaction tx = null;
try {
FacesContext context = FacesContext.getCurrentInstance();
tx = Repository.getUserTransaction(context);
tx.begin();
List<String> shortcuts = getShortcutList(context);
if (shortcuts.size() > shortcutEvent.Index) {
// remove the shortcut from the saved list and persist back
shortcuts.remove(shortcutEvent.Index);
PreferencesService.getPreferences(context).setValue(PREF_SHORTCUTS, (Serializable) shortcuts);
// commit the transaction
tx.commit();
// remove shortcut Node from the in-memory list
Node node = getShortcuts().remove(shortcutEvent.Index);
if (logger.isDebugEnabled())
logger.debug("Removed deleted node: " + node.getName() + " from the user shortcuts list.");
}
} catch (Throwable err) {
try {
if (tx != null) {
tx.rollback();
}
} catch (Exception tex) {
}
}
}
}
use of org.alfresco.service.cmr.dictionary.DictionaryService in project alfresco-remote-api by Alfresco.
the class WorkflowModelBuilderTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
namespaceService = new NamespaceServiceMemoryImpl();
namespaceService.registerNamespace("test", URI);
namespaceService.registerNamespace(NamespaceService.CONTENT_MODEL_PREFIX, NamespaceService.CONTENT_MODEL_1_0_URI);
namespaceService.registerNamespace(NamespaceService.BPM_MODEL_PREFIX, NamespaceService.BPM_MODEL_1_0_URI);
personService = mock(PersonService.class);
when(personService.getPerson(userName)).thenReturn(person);
when(personService.personExists(userName)).thenReturn(true);
nodeService = mock(NodeService.class);
Map<QName, Serializable> personProps = new HashMap<QName, Serializable>();
personProps.put(ContentModel.PROP_USERNAME, userName);
personProps.put(ContentModel.PROP_FIRSTNAME, firstName);
personProps.put(ContentModel.PROP_LASTNAME, lastName);
when(nodeService.getProperties(person)).thenReturn(personProps);
when(nodeService.getProperty(person, ContentModel.PROP_USERNAME)).thenReturn(userName);
when(nodeService.getProperty(person, ContentModel.PROP_FIRSTNAME)).thenReturn(firstName);
when(nodeService.getProperty(person, ContentModel.PROP_LASTNAME)).thenReturn(lastName);
workflowService = mock(WorkflowService.class);
dictionaryService = mock(DictionaryService.class);
authenticationService = mock(AuthenticationService.class);
builder = new WorkflowModelBuilder(namespaceService, nodeService, authenticationService, personService, workflowService, dictionaryService);
}
Aggregations