本文整理汇总了Java中org.apache.catalina.util.XMLWriter类的典型用法代码示例。如果您正苦于以下问题:Java XMLWriter类的具体用法?Java XMLWriter怎么用?Java XMLWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XMLWriter类属于org.apache.catalina.util包,在下文中一共展示了XMLWriter类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseProperties
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* If a directory does not have files or folders under it then this
* method generates the necessary xml
*
* @param context Description of the Parameter
* @param resources Description of the Parameter
* @param generatedXML Description of the Parameter
* @param propertiesVector Description of the Parameter
* @throws java.io.IOException Description of the Exception
*/
private void parseProperties(ActionContext context, ModuleContext resources,
XMLWriter generatedXML, Vector propertiesVector) throws IOException {
generatedXML.writeElement(null, "response", XMLWriter.OPENING);
String status = new String(
"HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND
+ " " + WebdavStatus.getStatusText
(WebdavStatus.SC_NOT_FOUND));
generatedXML.writeElement(null, "propstat", XMLWriter.OPENING);
generatedXML.writeElement(null, "prop", XMLWriter.OPENING);
generatedXML.writeElement(null, "prop", XMLWriter.CLOSING);
generatedXML.writeElement(null, "status", XMLWriter.OPENING);
generatedXML.writeText(status);
generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
generatedXML.writeElement(null, "propstat", XMLWriter.CLOSING);
generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
}
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:29,代码来源:WebdavServlet.java
示例2: if
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path Path
* @param generatedXML XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery
(String path, XMLWriter generatedXML) {
LockInfo resourceLock = resourceLocks.get(path);
Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null) {
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements()) {
LockInfo currentLock = collectionLocksList.nextElement();
if (path.startsWith(currentLock.path)) {
if (!wroteStart) {
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery",
XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart) {
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
} else {
return false;
}
return true;
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:43,代码来源:WebdavServlet.java
示例3: if
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path Path
* @param generatedXML XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery
(String path, XMLWriter generatedXML) {
LockInfo resourceLock = resourceLocks.get(path);
Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null) {
wroteStart = true;
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements()) {
LockInfo currentLock = collectionLocksList.nextElement();
if (path.startsWith(currentLock.path)) {
if (!wroteStart) {
wroteStart = true;
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart) {
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.CLOSING);
} else {
return false;
}
return true;
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:45,代码来源:WebdavServlet.java
示例4: if
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path Path
* @param generatedXML XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery
(String path, XMLWriter generatedXML) {
LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
Enumeration collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null) {
wroteStart = true;
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements()) {
LockInfo currentLock =
(LockInfo) collectionLocksList.nextElement();
if (path.startsWith(currentLock.path)) {
if (!wroteStart) {
wroteStart = true;
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart) {
generatedXML.writeElement(null, "lockdiscovery",
XMLWriter.CLOSING);
} else {
return false;
}
return true;
}
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:46,代码来源:WebdavServlet.java
示例5: generateLockDiscovery
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path
* Path
* @param generatedXML
* XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery(String path, XMLWriter generatedXML) {
LockInfo resourceLock = resourceLocks.get(path);
Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null) {
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements()) {
LockInfo currentLock = collectionLocksList.nextElement();
if (path.startsWith(currentLock.path)) {
if (!wroteStart) {
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart) {
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
} else {
return false;
}
return true;
}
开发者ID:how2j,项目名称:lazycat,代码行数:43,代码来源:WebdavServlet.java
示例6: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will append an XML fragment to the given XML writer.
*/
// originally this called toXML( ... false). That causes
// the system to show a dummy lock name. That breaks
// Contribute. It also violates the RFC. Contribute uses
// PROPFIND to find the lock name. Furthermore, the RFC
// specifically prohibits hiding the lock name this way.
// Rather than treating the lock name as secret, it's
// better to check permissions, as I now do.
public void toXML(XMLWriter generatedXML)
{
toXML(generatedXML, true);
}
开发者ID:sakaiproject,项目名称:sakai,代码行数:15,代码来源:DavServlet.java
示例7: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the
* client.
*
* @param req Servlet request
* @param resp Servlet response
* @param errorList List of error to be displayed
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
Hashtable<String,Integer> errorList)
throws IOException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus",
XMLWriter.OPENING);
Enumeration<String> pathList = errorList.keys();
while (pathList.hasMoreElements()) {
String errorPath = pathList.nextElement();
int errorCode = errorList.get(errorPath).intValue();
generatedXML.writeElement("D", "response", XMLWriter.OPENING);
generatedXML.writeElement("D", "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
generatedXML.writeElement("D", "status", XMLWriter.OPENING);
generatedXML.writeText("HTTP/1.1 " + errorCode + " "
+ WebdavStatus.getStatusText(errorCode));
generatedXML.writeElement("D", "status", XMLWriter.CLOSING);
generatedXML.writeElement("D", "response", XMLWriter.CLOSING);
}
generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:54,代码来源:WebdavServlet.java
示例8: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will
* append an XML fragment to the given XML writer.
*/
public void toXML(XMLWriter generatedXML) {
generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);
generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);
generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);
generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
if (depth == maxDepth) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);
generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
generatedXML.writeText(owner);
generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);
generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
generatedXML.writeText("Second-" + timeout);
generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);
generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
Enumeration<String> tokensList = tokens.elements();
while (tokensList.hasMoreElements()) {
generatedXML.writeElement("D", "href", XMLWriter.OPENING);
generatedXML.writeText("opaquelocktoken:"
+ tokensList.nextElement());
generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
}
generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);
generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);
}
开发者ID:liaokailin,项目名称:tomcat7,代码行数:47,代码来源:WebdavServlet.java
示例9: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the
* client.
*
* @param req Servlet request
* @param resp Servlet response
* @param errorList List of error to be displayed
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
Hashtable<String,Integer> errorList)
throws ServletException, IOException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement(null, "multistatus"
+ generateNamespaceDeclarations(),
XMLWriter.OPENING);
Enumeration<String> pathList = errorList.keys();
while (pathList.hasMoreElements()) {
String errorPath = pathList.nextElement();
int errorCode = errorList.get(errorPath).intValue();
generatedXML.writeElement(null, "response", XMLWriter.OPENING);
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
generatedXML.writeElement(null, "status", XMLWriter.OPENING);
generatedXML
.writeText("HTTP/1.1 " + errorCode + " "
+ WebdavStatus.getStatusText(errorCode));
generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:56,代码来源:WebdavServlet.java
示例10: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will
* append an XML fragment to the given XML writer.
*/
public void toXML(XMLWriter generatedXML) {
generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);
generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);
generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);
generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
if (depth == maxDepth) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);
generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
generatedXML.writeText(owner);
generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);
generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
generatedXML.writeText("Second-" + timeout);
generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);
generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
Enumeration<String> tokensList = tokens.elements();
while (tokensList.hasMoreElements()) {
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
generatedXML.writeText("opaquelocktoken:"
+ tokensList.nextElement());
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);
generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:47,代码来源:WebdavServlet.java
示例11: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the
* client.
*
* @param req Servlet request
* @param resp Servlet response
* @param errorList List of error to be displayed
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
Hashtable errorList)
throws ServletException, IOException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement(null, "multistatus"
+ generateNamespaceDeclarations(),
XMLWriter.OPENING);
Enumeration pathList = errorList.keys();
while (pathList.hasMoreElements()) {
String errorPath = (String) pathList.nextElement();
int errorCode = ((Integer) errorList.get(errorPath)).intValue();
generatedXML.writeElement(null, "response", XMLWriter.OPENING);
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
generatedXML.writeElement(null, "status", XMLWriter.OPENING);
generatedXML
.writeText("HTTP/1.1 " + errorCode + " "
+ WebdavStatus.getStatusText(errorCode));
generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:56,代码来源:WebdavServlet.java
示例12: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will
* append an XML fragment to the given XML writer.
*/
public void toXML(XMLWriter generatedXML, boolean showToken) {
generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);
generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);
generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);
generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
if (depth == INFINITY) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);
generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
generatedXML.writeText(owner);
generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);
generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
generatedXML.writeText("Second-" + timeout);
generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);
generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
if (showToken) {
Enumeration tokensList = tokens.elements();
while (tokensList.hasMoreElements()) {
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
generatedXML.writeText("opaquelocktoken:"
+ tokensList.nextElement());
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
}
} else {
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
generatedXML.writeText("opaquelocktoken:dummytoken");
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);
generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);
}
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:53,代码来源:WebdavServlet.java
示例13: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the
* client.
*
* @param req
* Servlet request
* @param resp
* Servlet response
* @param errorList
* List of error to be displayed
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String, Integer> errorList)
throws IOException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING);
Enumeration<String> pathList = errorList.keys();
while (pathList.hasMoreElements()) {
String errorPath = pathList.nextElement();
int errorCode = errorList.get(errorPath).intValue();
generatedXML.writeElement("D", "response", XMLWriter.OPENING);
generatedXML.writeElement("D", "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/"))
toAppend = "/" + toAppend;
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
generatedXML.writeElement("D", "status", XMLWriter.OPENING);
generatedXML.writeText("HTTP/1.1 " + errorCode + " " + WebdavStatus.getStatusText(errorCode));
generatedXML.writeElement("D", "status", XMLWriter.CLOSING);
generatedXML.writeElement("D", "response", XMLWriter.CLOSING);
}
generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:how2j,项目名称:lazycat,代码行数:54,代码来源:WebdavServlet.java
示例14: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will append
* an XML fragment to the given XML writer.
*/
public void toXML(XMLWriter generatedXML) {
generatedXML.writeElement("D", "activelock", XMLWriter.OPENING);
generatedXML.writeElement("D", "locktype", XMLWriter.OPENING);
generatedXML.writeElement("D", type, XMLWriter.NO_CONTENT);
generatedXML.writeElement("D", "locktype", XMLWriter.CLOSING);
generatedXML.writeElement("D", "lockscope", XMLWriter.OPENING);
generatedXML.writeElement("D", scope, XMLWriter.NO_CONTENT);
generatedXML.writeElement("D", "lockscope", XMLWriter.CLOSING);
generatedXML.writeElement("D", "depth", XMLWriter.OPENING);
if (depth == maxDepth) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement("D", "depth", XMLWriter.CLOSING);
generatedXML.writeElement("D", "owner", XMLWriter.OPENING);
generatedXML.writeText(owner);
generatedXML.writeElement("D", "owner", XMLWriter.CLOSING);
generatedXML.writeElement("D", "timeout", XMLWriter.OPENING);
long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
generatedXML.writeText("Second-" + timeout);
generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING);
generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING);
Enumeration<String> tokensList = tokens.elements();
while (tokensList.hasMoreElements()) {
generatedXML.writeElement("D", "href", XMLWriter.OPENING);
generatedXML.writeText("opaquelocktoken:" + tokensList.nextElement());
generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
}
generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING);
generatedXML.writeElement("D", "activelock", XMLWriter.CLOSING);
}
开发者ID:how2j,项目名称:lazycat,代码行数:46,代码来源:WebdavServlet.java
示例15: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the client.
*
* @param req
* Servlet request
* @param resp
* Servlet response
* @param errorList
* List of error to be displayed
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp, Hashtable<String,Integer> errorList) throws ServletException,
IOException
{
resp.setStatus(SakaidavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement("D", "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING);
Enumeration<String> pathList = errorList.keys();
while (pathList.hasMoreElements())
{
String errorPath = pathList.nextElement();
int errorCode = ((Integer) errorList.get(errorPath)).intValue();
generatedXML.writeElement("D", "response", XMLWriter.OPENING);
generatedXML.writeElement("D", "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/")) toAppend = "/" + toAppend;
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement("D", "href", XMLWriter.CLOSING);
generatedXML.writeElement("D", "status", XMLWriter.OPENING);
generatedXML.writeText("HTTP/1.1 " + errorCode + " " + SakaidavStatus.getStatusText(errorCode));
generatedXML.writeElement("D", "status", XMLWriter.CLOSING);
generatedXML.writeElement("D", "response", XMLWriter.CLOSING);
}
generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:sakaiproject,项目名称:sakai,代码行数:54,代码来源:DavServlet.java
示例16: generateLockDiscovery
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path
* Path
* @param generatedXML
* XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery(String path, XMLWriter generatedXML)
{
LockInfo resourceLock = (LockInfo) resourceLocks.get(path);
Enumeration<LockInfo> collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null)
{
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements())
{
LockInfo currentLock = (LockInfo) collectionLocksList.nextElement();
if (path.startsWith(currentLock.path))
{
if (!wroteStart)
{
wroteStart = true;
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart)
{
generatedXML.writeElement("D", "lockdiscovery", XMLWriter.CLOSING);
}
else
{
return false;
}
return true;
}
开发者ID:sakaiproject,项目名称:sakai,代码行数:51,代码来源:DavServlet.java
示例17: sendReport
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Send a multistatus element containing a complete error report to the
* client.
*
* @param req Servlet request
* @param resp Servlet response
* @param errorList List of error to be displayed
* @throws javax.servlet.ServletException Description of the Exception
* @throws java.io.IOException Description of the Exception
*/
private void sendReport(HttpServletRequest req, HttpServletResponse resp,
Hashtable errorList)
throws ServletException, IOException {
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
String absoluteUri = req.getRequestURI();
String relativePath = getRelativePath(req);
XMLWriter generatedXML = new XMLWriter();
generatedXML.writeXMLHeader();
generatedXML.writeElement(
null, "multistatus"
+ generateNamespaceDeclarations(),
XMLWriter.OPENING);
Enumeration pathList = errorList.keys();
while (pathList.hasMoreElements()) {
String errorPath = (String) pathList.nextElement();
int errorCode = ((Integer) errorList.get(errorPath)).intValue();
generatedXML.writeElement(null, "response", XMLWriter.OPENING);
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
String toAppend = errorPath.substring(relativePath.length());
if (!toAppend.startsWith("/")) {
toAppend = "/" + toAppend;
}
generatedXML.writeText(absoluteUri + toAppend);
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
generatedXML.writeElement(null, "status", XMLWriter.OPENING);
generatedXML.writeText(
"HTTP/1.1 " + errorCode + " "
+ WebdavStatus.getStatusText(errorCode));
generatedXML.writeElement(null, "status", XMLWriter.CLOSING);
generatedXML.writeElement(null, "response", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
}
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:60,代码来源:WebdavServlet.java
示例18: if
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Print the lock discovery information associated with a path.
*
* @param path Path
* @param generatedXML XML data to which the locks info will be appended
* @return true if at least one lock was displayed
*/
private boolean generateLockDiscovery
(String path, XMLWriter generatedXML) {
WebdavServlet.LockInfo resourceLock = (WebdavServlet.LockInfo) resourceLocks.get(path);
Enumeration collectionLocksList = collectionLocks.elements();
boolean wroteStart = false;
if (resourceLock != null) {
wroteStart = true;
generatedXML.writeElement(
null, "lockdiscovery",
XMLWriter.OPENING);
resourceLock.toXML(generatedXML);
}
while (collectionLocksList.hasMoreElements()) {
WebdavServlet.LockInfo currentLock =
(WebdavServlet.LockInfo) collectionLocksList.nextElement();
if (path.startsWith(currentLock.path)) {
if (!wroteStart) {
wroteStart = true;
generatedXML.writeElement(
null, "lockdiscovery",
XMLWriter.OPENING);
}
currentLock.toXML(generatedXML);
}
}
if (wroteStart) {
generatedXML.writeElement(
null, "lockdiscovery",
XMLWriter.CLOSING);
} else {
return false;
}
return true;
}
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:48,代码来源:WebdavServlet.java
示例19: toXML
import org.apache.catalina.util.XMLWriter; //导入依赖的package包/类
/**
* Get an XML representation of this lock token. This method will append an
* XML fragment to the given XML writer.
*
* @param generatedXML Description of the Parameter
*/
public void toXML(XMLWriter generatedXML) {
generatedXML.writeElement(null, "activelock", XMLWriter.OPENING);
generatedXML.writeElement(null, "locktype", XMLWriter.OPENING);
generatedXML.writeElement(null, type, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "locktype", XMLWriter.CLOSING);
generatedXML.writeElement(null, "lockscope", XMLWriter.OPENING);
generatedXML.writeElement(null, scope, XMLWriter.NO_CONTENT);
generatedXML.writeElement(null, "lockscope", XMLWriter.CLOSING);
generatedXML.writeElement(null, "depth", XMLWriter.OPENING);
if (depth == INFINITY) {
generatedXML.writeText("Infinity");
} else {
generatedXML.writeText("0");
}
generatedXML.writeElement(null, "depth", XMLWriter.CLOSING);
generatedXML.writeElement(null, "owner", XMLWriter.OPENING);
generatedXML.writeText(owner);
generatedXML.writeElement(null, "owner", XMLWriter.CLOSING);
generatedXML.writeElement(null, "timeout", XMLWriter.OPENING);
long timeout = (expiresAt - System.currentTimeMillis()) / 1000;
generatedXML.writeText("Second-" + timeout);
generatedXML.writeElement(null, "timeout", XMLWriter.CLOSING);
generatedXML.writeElement(null, "locktoken", XMLWriter.OPENING);
Enumeration tokensList = tokens.elements();
while (tokensList.hasMoreElements()) {
generatedXML.writeElement(null, "href", XMLWriter.OPENING);
generatedXML.writeText(
"opaquelocktoken:"
+ tokensList.nextElement());
generatedXML.writeElement(null, "href", XMLWriter.CLOSING);
}
generatedXML.writeElement(null, "locktoken", XMLWriter.CLOSING);
generatedXML.writeElement(null, "activelock", XMLWriter.CLOSING);
}
开发者ID:Concursive,项目名称:concourseconnect-community,代码行数:50,代码来源:WebdavServlet.java
注:本文中的org.apache.catalina.util.XMLWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论