use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class ActionFormProcessorTest method testGenerateFormWithSpecificLocale.
/**
* REPO-2253 Community: ALF-21854 Action parameter lookup for "de_DE" falls back to "root" locale instead of "de"
*/
@Test
public void testGenerateFormWithSpecificLocale() {
final Locale originalLocale = I18NUtil.getLocale();
try {
// de-DE
I18NUtil.setLocale(Locale.GERMANY);
transactionHelper.doInTransaction(() -> {
Form form = formService.getForm(new Item(ActionFormProcessor.ITEM_KIND, "transform"));
// Field definitions keyed by name.
Map<String, FieldDefinition> fieldDefMap = form.getFieldDefinitions().stream().collect(Collectors.toMap(FieldDefinition::getName, Function.identity()));
assertEquals("Zielordner", fieldDefMap.get(TransformActionExecuter.PARAM_DESTINATION_FOLDER).getLabel());
assertEquals("MIME-Type", fieldDefMap.get(TransformActionExecuter.PARAM_MIME_TYPE).getLabel());
return null;
});
} finally {
I18NUtil.setLocale(originalLocale);
}
}
use of org.alfresco.repo.forms.Item in project records-management by Alfresco.
the class RM1727Test method testRM1727.
public void testRM1727() {
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
// set read and file permissions for folder
filePlanPermissionService.setPermission(folder, myUser, RMPermissionModel.FILING);
return null;
}
});
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Item item = new Item("node", folder.toString());
item.setType("rma:recordFolder");
form = new Form(item);
nodeFormFilter.afterGenerate(folder, null, null, form, null);
return null;
}
}, myUser);
doTestInTransaction(new Test<Void>() {
@Override
public Void run() {
Item item = new Item("node", record.toString());
item.setType("rma:record");
form = new Form(item);
nodeFormFilter.afterGenerate(record, null, null, form, null);
return null;
}
}, myUser);
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class ScriptFormService method getForm.
/**
* Returns a form representation of the given item consisting
* only of the given fields.
*
* @param itemKind The kind of item to retrieve a form for
* @param itemId The identifier of the item to retrieve a form for
* @param fields String array of fields to include, null
* indicates all possible fields for the item
* should be included
* @param forcedFields List of field names from 'fields' list
* that should be forcibly included, it is
* up to the form processor implementation
* to determine how to enforce this
* @return The form
*/
public ScriptForm getForm(String itemKind, String itemId, String[] fields, String[] forcedFields) {
// create List<String> representations of field params if necessary
List<String> fieldsList = null;
List<String> forcedFieldsList = null;
if (fields != null) {
fieldsList = Arrays.asList(fields);
}
if (forcedFields != null) {
forcedFieldsList = Arrays.asList(forcedFields);
}
Form result = formService.getForm(new Item(itemKind, itemId), fieldsList, forcedFieldsList);
return result == null ? null : new ScriptForm(result);
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class FilteredFormProcessor method internalGenerate.
/**
* Generates the form.
*
* @param item The object to generate a form for
* @param fields Restricted list of fields to include
* @param forcedFields List of fields to forcibly include
* @param form The form object being generated
* @param context Map representing optional context that can be used during
* retrieval of the form
*/
protected void internalGenerate(ItemType item, List<String> fields, List<String> forcedFields, Form form, Map<String, Object> context) {
Log log = getLogger();
if (log.isDebugEnabled())
log.debug("Generating form for: " + item);
// generate the form type and URI for the item.
Item formItem = form.getItem();
formItem.setType(getItemType(item));
formItem.setUrl(getItemURI(item));
Object itemData = makeItemData(item);
FormCreationData data = new FormCreationDataImpl(itemData, forcedFields, context);
populateForm(form, fields, data);
if (//
log.isDebugEnabled())
log.debug("Generated form: " + form);
}
use of org.alfresco.repo.forms.Item in project alfresco-repository by Alfresco.
the class ActionFormProcessorTest method testRequestFormForNonExistentAction.
@Test
public void testRequestFormForNonExistentAction() throws Exception {
try {
this.formService.getForm(new Item(ActionFormProcessor.ITEM_KIND, "noSuchActionBean"));
fail("Expected FormNotFoundException");
} catch (FormNotFoundException e) {
// NOOP
}
}
Aggregations