List of usage examples for org.dom4j DocumentHelper createElement
public static Element createElement(String name)
From source file:itensil.workflow.activities.ActivityXML.java
License:Open Source License
public static Element display(Activity activity) { Element elem = DocumentHelper.createElement("activity"); elem.addAttribute("id", activity.getId()); if (activity.getParent() != null) elem.addAttribute("parent", activity.getParent().getId()); FlowState fstate = activity.getFlow(); elem.addAttribute("flow", fstate.getId()); try {/*from w w w . j a v a 2 s . co m*/ elem.addAttribute("flowName", UriHelper.name(fstate.getNode().getUri())); } catch (Exception ex) { // eat it } String icon = "defIco"; try { String style = activity.getFlow().getNode().getPropertyValue(PropertyHelper.itensilQName("style")); if (!Check.isEmpty(style) && style.startsWith("icon:")) icon = style.substring(5); } catch (Exception ex) { } elem.addAttribute("icon", icon); elem.addAttribute("name", activity.getName()); elem.addAttribute("description", activity.getDescription()); elem.addAttribute("activeKids", String.valueOf(activity.getActiveChildren().size())); elem.addAttribute("submitId", activity.getSubmitId()); elem.addAttribute("contextGroup", activity.getContextGroupId()); if (activity.getTimeStamp() != null) elem.addAttribute("timeStamp", dateFmtZ.format(activity.getTimeStamp())); elem.addAttribute("priority", String.valueOf(activity.getPriority())); elem.addAttribute("startDate", activity.getStartDate() != null ? dateFmtZ.format(activity.getStartDate()) : ""); elem.addAttribute("dueDate", activity.getDueDate() != null ? dateFmtZ.format(activity.getDueDate()) : ""); elem.addAttribute("duration", String.valueOf(activity.getDuration())); elem.addAttribute("variationId", activity.getVariationId()); for (ActivityStepState state : activity.getStates().values()) { Element stElem = elem.addElement("state"); stElem.addAttribute("txId", state.getTxId()); stElem.addAttribute("stepId", state.getStepId()); stElem.addAttribute("assignId", state.getAssignId()); stElem.addAttribute("subState", state.getSubState().toString()); stElem.addAttribute("progress", String.valueOf(state.getProgress())); stElem.addAttribute("subActivityId", state.getSubActivityId()); if (state.getTimeStamp() != null) stElem.addAttribute("timeStamp", dateFmtZ.format(state.getTimeStamp())); if (state.getExpireTime() != null) stElem.addAttribute("expireTime", dateFmtZ.format(state.getExpireTime())); stElem.addAttribute("userStatus", String.valueOf(state.getUserStatus())); ActivityCurrentPlan plan = state.getCurrentPlan(); if (plan != null) { Element curElem = stElem.addElement("current"); curElem.addAttribute("priority", String.valueOf(plan.getPriority())); curElem.addAttribute("startDate", plan.getStartDate() != null ? dateFmtZ.format(plan.getStartDate()) : ""); curElem.addAttribute("dueDate", plan.getDueDate() != null ? dateFmtZ.format(plan.getDueDate()) : ""); curElem.addAttribute("duration", String.valueOf(plan.getDuration())); } } return elem; }
From source file:itensil.workflow.activities.ActivityXML.java
License:Open Source License
/** * /*from w ww . j a v a 2s. c o m*/ * @param activity * @return * @throws StateException */ public static Element logs(Activity activity, Pair<Date, Date> minMaxDates) throws StateException { Element elem = DocumentHelper.createElement("logs"); ActivityStateStore store = new ActivityStateStore(activity.getFlow()); for (StepLog<Activity> slog : store.getLogSteps(activity, null)) { FlowStepLog fslog = (FlowStepLog) slog; Element lElem = elem.addElement("log"); lElem.addAttribute("stepId", Check.emptyIfNull(fslog.getStepId())); lElem.addAttribute("subState", fslog.getSubState().toString()); if (fslog.getTimeStamp() != null) { if (minMaxDates.first == null || minMaxDates.first.after(fslog.getTimeStamp())) { minMaxDates.first = fslog.getTimeStamp(); } if (minMaxDates.second == null || minMaxDates.second.before(fslog.getTimeStamp())) { minMaxDates.second = fslog.getTimeStamp(); } lElem.addAttribute("timeStamp", dateFmtZ.format(fslog.getTimeStamp())); } else { lElem.addAttribute("timeStamp", ""); } lElem.addAttribute("userId", fslog.getUserId()); } return elem; }
From source file:itensil.workflow.activities.ActivityXML.java
License:Open Source License
/** * /*from w w w.j av a 2s. c o m*/ * @param activity * @return */ public static Element plans(Activity activity, Pair<Date, Date> minMaxDates) { Element elem = DocumentHelper.createElement("plans"); for (ActivityPlan plan : activity.getPlans().values()) { Element pElem = elem.addElement("plan"); pElem.addAttribute("priority", String.valueOf(plan.getPriority())); if (plan.getStartDate() != null) { if (minMaxDates.first == null || minMaxDates.first.after(plan.getStartDate())) { minMaxDates.first = plan.getStartDate(); } pElem.addAttribute("startDate", dateFmtZ.format(plan.getStartDate())); } else { pElem.addAttribute("startDate", ""); } if (plan.getDueDate() != null) { if (minMaxDates.second == null || minMaxDates.second.before(plan.getDueDate())) { minMaxDates.second = plan.getDueDate(); } pElem.addAttribute("dueDate", dateFmtZ.format(plan.getDueDate())); } else { pElem.addAttribute("dueDate", ""); } pElem.addAttribute("duration", String.valueOf(plan.getDuration())); pElem.addAttribute("stepId", Check.emptyIfNull(plan.getStepId())); pElem.addAttribute("skip", plan.isSkip() ? "1" : "0"); pElem.addAttribute("assignId", Check.emptyIfNull(plan.getAssignId())); } return elem; }
From source file:itensil.workflow.activities.ActivityXML.java
License:Open Source License
public static Element data(Activity act, Map<String, Integer> columnMap) { Element elem = DocumentHelper.createElement("data"); String flowId = act.getFlow().getId(); mapColumn(act.getCust0Val(), "0", flowId, elem, columnMap); mapColumn(act.getCust1Val(), "1", flowId, elem, columnMap); mapColumn(act.getCust2Val(), "2", flowId, elem, columnMap); mapColumn(act.getCust3Val(), "3", flowId, elem, columnMap); mapColumn(act.getCust4Val(), "4", flowId, elem, columnMap); mapColumn(act.getCust5Val(), "5", flowId, elem, columnMap); mapColumn(act.getCust6Val(), "6", flowId, elem, columnMap); mapColumn(act.getCust7Val(), "7", flowId, elem, columnMap); mapColumn(act.getCust8Val(), "8", flowId, elem, columnMap); mapColumn(act.getCust9Val(), "9", flowId, elem, columnMap); mapColumn(act.getCustAVal(), "A", flowId, elem, columnMap); mapColumn(act.getCustBVal(), "B", flowId, elem, columnMap); return elem;// w w w . j ava 2 s .com }
From source file:jetsennet.orm.tableinfo.mapping.XmlReader.java
License:Apache License
@Override public Element read(String itemname, ResultSet result, ResultSetMetaData rsmd) throws Exception { Element dataElement = DocumentHelper.createElement(itemname); int count = rsmd.getColumnCount(); for (int i = 1; i <= count; i++) { String columnName = rsmd.getColumnLabel(i); if (null == columnName || 0 == columnName.length()) { columnName = rsmd.getColumnName(i); }//from w w w .j av a2 s. co m int columnType = rsmd.getColumnType(i); Element curElement = dataElement.addElement(columnName); String val = getValue(result, i, columnType); if (val != null) { curElement.addText(val); } } return dataElement; }
From source file:jp.aegif.alfresco.online_webdav.PropFindMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for a * specific set of properties//from w w w.j a va2 s.c o m * * @param xml XMLWriter * @param node NodeRef * @param isDir boolean */ private void generateNamedPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) throws Exception { // Get the properties for the node Map<QName, Serializable> props = nodeInfo.getProperties(); // Output the start of the properties element Attributes nullAttr = getDAVHelper().getNullAttributes(); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr); ArrayList<WebDAVProperty> propertiesNotFound = new ArrayList<WebDAVProperty>(); TypeConverter typeConv = DefaultTypeConverter.INSTANCE; // Loop through the requested property list for (WebDAVProperty property : m_properties) { // Get the requested property details String propName = property.getName(); String propNamespaceUri = property.getNamespaceUri(); // Check if the property is a standard WebDAV property Object davValue = null; if (WebDAV.DEFAULT_NAMESPACE_URI.equals(propNamespaceUri)) { // Check if the client is requesting lock information if (propName.equals(WebDAV.XML_LOCK_DISCOVERY)) // && metaData.isLocked()) { generateLockDiscoveryResponse(xml, nodeInfo, isDir); } else if (propName.equals(WebDAV.XML_SUPPORTED_LOCK)) { // Output the supported lock types writeLockTypes(xml); } // Check if the client is requesting the resource type else if (propName.equals(WebDAV.XML_RESOURCE_TYPE)) { // If the node is a folder then return as a collection type xml.startElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE, nullAttr); if (isDir) { xml.write(DocumentHelper.createElement(WebDAV.XML_NS_COLLECTION)); } xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE); } else if (propName.equals(WebDAV.XML_DISPLAYNAME)) { // Get the node name //AEGIF add null check if (getRootNodeRef() != null && getRootNodeRef().equals(nodeInfo.getNodeRef())) { // Output an empty name for the root node xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE)); } else { // Get the node name davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_DISPLAYNAME); // Output the node name xml.startElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME, nullAttr); if (davValue != null) { String name = typeConv.convert(String.class, davValue); if (name == null || name.length() == 0) { logger.error("WebDAV name is null, value=" + davValue.getClass().getName() + ", node=" + nodeInfo.getNodeRef()); } xml.write(name); } xml.endElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME); } } else if (propName.equals(WebDAV.XML_SOURCE)) { // NOTE: source is always a no content element in our // implementation xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE)); } else if (propName.equals(WebDAV.XML_GET_LAST_MODIFIED)) { // Get the modifed date/time davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_LAST_MODIFIED); // Output the last modified date of the node xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED, nullAttr); if (davValue != null) xml.write(WebDAV.formatModifiedDate(typeConv.convert(Date.class, davValue))); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED); } else if (propName.equals(WebDAV.XML_GET_CONTENT_LANGUAGE) && !isDir) { // Get the content language // TODO: // Output the content language xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE, nullAttr); // TODO: xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE); } else if (propName.equals(WebDAV.XML_GET_CONTENT_TYPE) && !isDir) { // Get the content type davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_CONTENT_TYPE); // Output the content type xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE, nullAttr); if (davValue != null) xml.write(typeConv.convert(String.class, davValue)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE); } else if (propName.equals(WebDAV.XML_GET_ETAG) && !isDir) { // Output the etag xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG, nullAttr); xml.write(getDAVHelper().makeETag(nodeInfo)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG); } else if (propName.equals(WebDAV.XML_GET_CONTENT_LENGTH)) { // Get the content length, if it's not a folder long len = 0; if (!isDir) { ContentData contentData = (ContentData) props.get(ContentModel.PROP_CONTENT); if (contentData != null) len = contentData.getSize(); } // Output the content length xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH, nullAttr); xml.write("" + len); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH); } else if (propName.equals(WebDAV.XML_CREATION_DATE)) { // Get the creation date davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_CREATION_DATE); // Output the creation date xml.startElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE, nullAttr); if (davValue != null) xml.write(WebDAV.formatCreationDate(typeConv.convert(Date.class, davValue))); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE); } else if (propName.equals(WebDAV.XML_ALF_AUTHTICKET)) { // Get the users authentication ticket SessionUser davUser = (SessionUser) m_request.getSession() .getAttribute(AuthenticationFilter.AUTHENTICATION_USER); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET, nullAttr); if (davUser != null) xml.write(davUser.getTicket()); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET); } else { // Could not map the requested property to an Alfresco property if (property.getName().equals(WebDAV.XML_HREF) == false) propertiesNotFound.add(property); } } else { // Look in the custom properties // TODO: Custom properties lookup // String qualifiedName = propNamespaceUri + WebDAV.NAMESPACE_SEPARATOR + propName; String value = (String) nodeInfo.getProperties().get(property.createQName()); if (value == null) { propertiesNotFound.add(property); } else { if (property.hasNamespaceName()) { xml.startElement(property.getNamespaceName(), property.getName(), property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName(), nullAttr); xml.write(value); xml.endElement(property.getNamespaceName(), property.getName(), property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName()); } else { xml.startElement("", property.getName(), property.getName(), nullAttr); xml.write(value); xml.endElement("", property.getName(), property.getName()); } } } } // Close off the successful part of the response xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr); xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT); // If some of the requested properties were not found return another // status section if (propertiesNotFound.size() > 0) { // Start the second status section xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr); // Loop through the list of properties that were not found for (WebDAVProperty property : propertiesNotFound) { // Output the property not found status block String propName = property.getName(); String propNamespaceName = property.getNamespaceName(); String propQName = propName; if (propNamespaceName != null && propNamespaceName.length() > 0) propQName = propNamespaceName + ":" + propName; xml.write(DocumentHelper.createElement(propQName)); } // Close the unsuccessful part of the response xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr); xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_NOT_FOUND + " " + WebDAV.SC_NOT_FOUND_DESC); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT); } }
From source file:jp.aegif.alfresco.online_webdav.PropFindMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for all known * properties//from w ww . j a v a 2 s . com * * @param xml XMLWriter * @param node NodeRef * @param isDir boolean */ protected void generateAllPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, String path, boolean isDir) throws Exception { // Get the properties for the node //## specific boolean isRealContent = (nodeInfo != null); Map<QName, Serializable> props = null; if (isRealContent) { props = nodeInfo.getProperties(); } // Output the start of the properties element Attributes nullAttr = getDAVHelper().getNullAttributes(); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr); // Generate a lock status report, if locked if (isRealContent) { generateLockDiscoveryResponse(xml, nodeInfo, isDir); } // Output the supported lock types writeLockTypes(xml); // If the node is a folder then return as a collection type xml.startElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE, nullAttr); if (isDir) xml.write(DocumentHelper.createElement(WebDAV.XML_NS_COLLECTION)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_RESOURCE_TYPE, WebDAV.XML_NS_RESOURCE_TYPE); // Get the node name Object davValue = null; TypeConverter typeConv = DefaultTypeConverter.INSTANCE; if (isRealContent) { davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_DISPLAYNAME); //TypeConverter typeConv = DefaultTypeConverter.INSTANCE; // Output the node name xml.startElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME, nullAttr); if (davValue != null) { String name = typeConv.convert(String.class, davValue); if (name == null || name.length() == 0) { logger.error("WebDAV name is null, value=" + davValue.getClass().getName() + ", node=" + nodeInfo.getNodeRef()); } xml.write(name); } xml.endElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME); } else { xml.startElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME, nullAttr); xml.write(path.replaceAll("/", "")); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_DISPLAYNAME, WebDAV.XML_NS_DISPLAYNAME); } // Output the source // // NOTE: source is always a no content element in our implementation xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SOURCE)); // Get the creation date if (isRealContent) { davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_CREATION_DATE); } else { davValue = new Date(); } // Output the creation date xml.startElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE, nullAttr); if (davValue != null) xml.write(WebDAV.formatCreationDate(typeConv.convert(Date.class, davValue))); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_CREATION_DATE, WebDAV.XML_NS_CREATION_DATE); // Get the modifed date/time if (isRealContent) { davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_LAST_MODIFIED); } else { davValue = new Date(); } // Output the last modified date of the node xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED, nullAttr); if (davValue != null) xml.write(WebDAV.formatModifiedDate(typeConv.convert(Date.class, davValue))); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_LAST_MODIFIED, WebDAV.XML_NS_GET_LAST_MODIFIED); // For a file node output the content language and content type if (isDir == false) { // Get the content language // TODO: // Output the content language xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE, nullAttr); // TODO: xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LANGUAGE, WebDAV.XML_NS_GET_CONTENT_LANGUAGE); // Get the content type davValue = WebDAV.getDAVPropertyValue(props, WebDAV.XML_GET_CONTENT_TYPE); // Output the content type xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE, nullAttr); if (davValue != null) xml.write(typeConv.convert(String.class, davValue)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_TYPE, WebDAV.XML_NS_GET_CONTENT_TYPE); // Output the etag xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG, nullAttr); xml.write(getDAVHelper().makeETag(nodeInfo)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_ETAG, WebDAV.XML_NS_GET_ETAG); } // Get the content length, if it's not a folder long len = 0; if (isDir == false) { ContentData contentData = (ContentData) props.get(ContentModel.PROP_CONTENT); if (contentData != null) len = contentData.getSize(); } // Output the content length xml.startElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH, nullAttr); xml.write("" + len); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_GET_CONTENT_LENGTH, WebDAV.XML_NS_GET_CONTENT_LENGTH); // Print out all the custom properties SessionUser davUser = (SessionUser) m_request.getSession() .getAttribute(AuthenticationFilter.AUTHENTICATION_USER); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET, nullAttr); if (davUser != null) xml.write(davUser.getTicket()); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_ALF_AUTHTICKET, WebDAV.XML_NS_ALF_AUTHTICKET); // Close off the response xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr); xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT); }
From source file:jp.aegif.alfresco.online_webdav.PropFindMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for a list of * all known properties//from ww w . j a v a 2 s.co m * * @param xml XMLWriter * @param node NodeRef * @param isDir boolean */ protected void generateFindPropertiesResponse(XMLWriter xml, FileInfo nodeInfo, boolean isDir) { try { // Output the start of the properties element Attributes nullAttr = getDAVHelper().getNullAttributes(); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr); // Output the well-known properties xml.write(DocumentHelper.createElement(WebDAV.XML_NS_LOCK_DISCOVERY)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_SUPPORTED_LOCK)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_RESOURCE_TYPE)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_DISPLAYNAME)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_LAST_MODIFIED)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LENGTH)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_CREATION_DATE)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_ETAG)); if (isDir) { xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_LANGUAGE)); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_GET_CONTENT_TYPE)); } // Output the custom properties xml.write(DocumentHelper.createElement(WebDAV.XML_NS_ALF_AUTHTICKET)); // Close off the response xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr); xml.write(WebDAV.HTTP1_1 + " " + HttpServletResponse.SC_OK + " " + WebDAV.SC_OK_DESC); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT); } catch (Exception ex) { // Convert to a runtime exception throw new AlfrescoRuntimeException("XML processing error", ex); } }
From source file:jp.aegif.alfresco.online_webdav.PropFindMethod.java
License:Open Source License
/** * Output the lockentry element of the specified type * @param xml XMLWriter/*from w w w.ja va 2 s . co m*/ * @param lockType lock type. Can be WebDAV.XML_NS_EXCLUSIVE or WebDAV.XML_NS_SHARED * @param lockType lock type containing namespace * @throws SAXException * @throws IOException */ private void writeLock(XMLWriter xml, String lockType) throws SAXException, IOException { AttributesImpl nullAttr = getDAVHelper().getNullAttributes(); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_ENTRY, WebDAV.XML_NS_LOCK_ENTRY, nullAttr); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE, nullAttr); xml.write(DocumentHelper.createElement(lockType)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_SCOPE, WebDAV.XML_NS_LOCK_SCOPE); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE, nullAttr); xml.write(DocumentHelper.createElement(WebDAV.XML_NS_WRITE)); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_TYPE, WebDAV.XML_NS_LOCK_TYPE); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_LOCK_ENTRY, WebDAV.XML_NS_LOCK_ENTRY); }
From source file:jp.aegif.alfresco.online_webdav.PropPatchMethod.java
License:Open Source License
/** * Generates the XML response for a PROPFIND request that asks for a list of * all known properties//from w w w . j a v a 2 s . co m * * @param xml XMLWriter * @param node NodeRef * @param isDir boolean */ protected void generatePropertyResponse(XMLWriter xml, WebDAVProperty property, int status, String description) { try { // Output the start of the properties element Attributes nullAttr = getDAVHelper().getNullAttributes(); xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT, nullAttr); // Output property name xml.startElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP, nullAttr); if (property.hasNamespaceName()) { xml.write(DocumentHelper.createElement( property.getNamespaceName() + WebDAV.NAMESPACE_SEPARATOR + property.getName())); } else { xml.write(DocumentHelper.createElement(property.getName())); } xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROP, WebDAV.XML_NS_PROP); // Output action result status xml.startElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS, nullAttr); xml.write(WebDAV.HTTP1_1 + " " + status + " " + description); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_STATUS, WebDAV.XML_NS_STATUS); xml.endElement(WebDAV.DAV_NS, WebDAV.XML_PROPSTAT, WebDAV.XML_NS_PROPSTAT); } catch (Exception ex) { // Convert to a runtime exception throw new AlfrescoRuntimeException("XML processing error", ex); } }