use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class UIWorkflowSummary method encodeBegin.
@Override
@SuppressWarnings("unchecked")
public void encodeBegin(FacesContext context) throws IOException {
if (!isRendered())
return;
WorkflowInstance wi = getValue();
if (wi != null) {
ResponseWriter out = context.getResponseWriter();
ResourceBundle bundle = Application.getBundle(context);
// output surrounding table and style if necessary
out.write("<table");
if (this.getAttributes().get("style") != null) {
out.write(" style=\"");
out.write((String) this.getAttributes().get("style"));
out.write("\"");
}
if (this.getAttributes().get("styleClass") != null) {
out.write(" class=\"");
out.write((String) this.getAttributes().get("styleClass"));
out.write("\"");
}
out.write(">");
// output the title and description
out.write("<tr><td>");
out.write(bundle.getString("title"));
out.write(":</td><td>");
out.write(wi.definition.title);
if (wi.definition.description != null && wi.definition.description.length() > 0) {
out.write(" (");
out.write(Utils.encode(wi.definition.description));
out.write(")");
}
out.write("</td></tr><tr><td>");
out.write(bundle.getString("initiated_by"));
out.write(":</td><td>");
NodeService nodeService = getNodeService(context);
if (wi.initiator != null) {
if (nodeService.exists(wi.initiator)) {
out.write(Utils.encode(User.getFullName(Repository.getServiceRegistry(context).getNodeService(), wi.initiator)));
} else {
out.write("<");
out.write(bundle.getString("unknown"));
out.write(">");
}
}
out.write("</td></tr><tr><td>");
out.write(bundle.getString("started_on"));
out.write(":</td><td>");
if (wi.startDate != null) {
out.write(Utils.getDateFormat(context).format(wi.startDate));
}
out.write("</td></tr><tr><td>");
out.write(bundle.getString("completed_on"));
out.write(":</td><td>");
if (wi.endDate != null) {
out.write(Utils.getDateFormat(context).format(wi.endDate));
} else {
out.write("<");
out.write(bundle.getString("in_progress"));
out.write(">");
}
out.write("</td></tr></table>");
}
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class UIContentSelector method encodeBegin.
/**
* @see javax.faces.component.UIComponent#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
if (isRendered() == false) {
return;
}
ResponseWriter out = context.getResponseWriter();
// get the child associations currently on the node and any that have been added
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
if (isDisabled()) {
// TODO: if the component is disabled just show the current value as text
} else {
// start outer table
out.write("<table border='0' cellspacing='4' cellpadding='0' class='");
if (this.getAttributes().get("styleClass") != null) {
out.write((String) this.getAttributes().get("styleClass"));
} else {
out.write("selector");
}
out.write("'");
if (this.getAttributes().get("style") != null) {
out.write(" style='");
out.write((String) this.getAttributes().get("style"));
out.write("'");
}
out.write(">");
// show the search field
out.write("<tr><td colspan='2'><input type='text' maxlength='1024' size='32' name='");
out.write(getClientId(context) + FIELD_CONTAINS);
out.write("'/> <input type='submit' value='");
out.write(Application.getMessage(context, MSG_SEARCH));
out.write("' onclick=\"");
out.write(generateFormSubmit(context, ACTION_SEARCH));
out.write("\"/></td></tr>");
// show available options i.e. all content in repository
renderAvailableOptions(context, out, nodeService);
// close table
out.write("</table>");
}
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class UILockIcon method encodeBegin.
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
if (isRendered() == false) {
return;
}
// get the value and see if the image is locked
NodeService nodeService = getNodeService(context);
String lockUser = null;
Object val = getValue();
NodeRef ref = null;
if (val instanceof NodeRef) {
ref = (NodeRef) val;
if (nodeService.exists(ref)) {
LockStatus lockStatus = Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getLockService().getLockStatus(ref);
if (lockStatus == LockStatus.LOCK_OWNER || lockStatus == LockStatus.LOCKED)
lockUser = (String) nodeService.getProperty(ref, ContentModel.PROP_LOCK_OWNER);
}
}
final boolean locked = lockUser != null;
final boolean lockedOwner = locked && (lockUser.equals(Application.getCurrentUser(context).getUserName()));
this.encodeBegin(context, locked, lockedOwner, new String[] { lockUser });
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class DisplayPathConverter method getAsString.
/**
* @see javax.faces.convert.Converter#getAsString(javax.faces.context.FacesContext, javax.faces.component.UIComponent, java.lang.Object)
*/
public String getAsString(FacesContext context, UIComponent component, Object value) throws ConverterException {
String result = "";
if (value != null) {
try {
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
Path path = null;
if (value instanceof NodeRef) {
path = nodeService.getPath((NodeRef) value);
} else if (value instanceof Path) {
path = (Path) value;
}
if (path != null) {
result = Repository.getNamePath(nodeService, path, null, "/", null);
}
} catch (AccessDeniedException accessErr) {
// use default if this occurs
} catch (InvalidNodeRefException nodeErr) {
// use default if this occurs
}
}
return result;
}
use of org.alfresco.service.cmr.repository.NodeService in project acs-community-packaging by Alfresco.
the class UIClipboardShelfItem method encodeBegin.
/**
* @see javax.faces.component.UIComponentBase#encodeBegin(javax.faces.context.FacesContext)
*/
public void encodeBegin(FacesContext context) throws IOException {
if (isRendered() == false) {
return;
}
ResponseWriter out = context.getResponseWriter();
List<ClipboardItem> items = getCollections();
out.write(SHELF_START);
if (items.size() != 0) {
DictionaryService dd = Repository.getServiceRegistry(context).getDictionaryService();
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
ResourceBundle bundle = Application.getBundle(context);
for (int i = 0; i < items.size(); i++) {
ClipboardItem item = items.get(i);
// check that the item has not been deleted since added to the clipboard
if (nodeService.exists(item.getNodeRef()) == false) {
// remove from clipboard
items.remove(i--);
continue;
}
// start row with cut/copy state icon
out.write("<tr><td width=16>");
if (item.getMode() == ClipboardStatus.COPY) {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_COPY, 14, 16, bundle.getString(MSG_COPY), null, "absmiddle"));
} else {
out.write(Utils.buildImageTag(context, WebResources.IMAGE_CUT, 13, 16, bundle.getString(MSG_CUT), null, "absmiddle"));
}
out.write("</td><td width=16>");
boolean isFolder = (dd.isSubClass(item.getType(), ContentModel.TYPE_FOLDER));
if (isFolder) {
// start row with correct node icon
String icon = (String) item.getIcon();
if (icon != null) {
icon = "/images/icons/" + icon + "-16.gif";
} else {
icon = WebResources.IMAGE_SPACE;
}
out.write(Utils.buildImageTag(context, icon, 16, 16, null, null, "absmiddle"));
} else {
String image = FileTypeImageUtils.getFileTypeImage(item.getName(), true);
out.write(Utils.buildImageTag(context, image, null, "absmiddle"));
}
// output cropped item label - we also output with no breaks, this is ok
// as the copped label will ensure a sensible maximum width
out.write("</td><td width=100%><nobr> ");
if (isFolder) {
out.write(Utils.cropEncode(item.getName()));
} else {
// output as a content download link
out.write("<a href='");
out.write(context.getExternalContext().getRequestContextPath());
out.write(generateBrowserURL(dd, nodeService, item));
out.write("' target='new'>");
out.write(Utils.cropEncode(item.getName()));
out.write("</a>");
}
// output actions
out.write("</nobr></td><td align=right><nobr>");
out.write(buildActionLink(ACTION_REMOVE_ITEM, i, bundle.getString(MSG_REMOVE_ITEM), WebResources.IMAGE_REMOVE));
out.write(" ");
out.write(buildActionLink(ACTION_PASTE_ITEM, i, bundle.getString(MSG_PASTE_ITEM), WebResources.IMAGE_PASTE));
if (item.supportsLink() && item.getMode() == ClipboardStatus.COPY && dd.isSubClass(item.getType(), ContentModel.TYPE_LINK) == false) {
out.write(" ");
out.write(buildActionLink(ACTION_PASTE_LINK, i, bundle.getString(MSG_PASTE_LINK), WebResources.IMAGE_PASTE_LINK));
}
// end actions cell and end row
out.write("</nobr></td></tr>");
}
// output general actions if any clipboard items are present
out.write("<tr><td colspan=4 style='padding-top:3px' align='center'><nobr>");
out.write(buildActionLink(ACTION_PASTE_ALL, -1, bundle.getString(MSG_PASTE_ALL), null));
out.write(" | ");
out.write(buildActionLink(ACTION_REMOVE_ALL, -1, bundle.getString(MSG_REMOVE_ALL), null));
out.write("</nobr></td><td></td></tr>");
}
out.write(SHELF_END);
}
Aggregations