public String getSupportedLock(DAVResource resource) { if (resource.isCollection()) { return null; } StringBuffer buffer = new StringBuffer(); buffer.append('\n'); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_ENTRY.getName(), SVNXMLUtil.XML_STYLE_NORMAL, null, buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_SCOPE.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.EXCLUSIVE.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_SCOPE.getName(), buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TYPE.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.WRITE.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); SVNXMLUtil.closeXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TYPE.getName(), buffer); SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_ENTRY.getName(), buffer); return buffer.toString(); }
public static DAVLock convertSVNLockToDAVLock(FSLock lock, boolean hideAuthUser, boolean exists) { String authUser = null; StringBuffer owner = null; if (lock.getComment() != null) { owner = new StringBuffer(); if (!lock.isDAVComment()) { List namespaces = new ArrayList(1); namespaces.add(DAVElement.DAV_NAMESPACE); owner = DAVXMLUtil.openNamespaceDeclarationTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_OWNER.getName(), namespaces, null, owner, false, false); owner.append(SVNEncodingUtil.xmlEncodeCDATA(lock.getComment(), true)); owner = SVNXMLUtil.addXMLFooter( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_OWNER.getName(), owner); } else { owner.append(lock.getComment()); } } if (!hideAuthUser) { authUser = lock.getOwner(); } return new DAVLock( authUser, DAVDepth.DEPTH_ZERO, exists, lock.getID(), owner != null ? owner.toString() : null, DAVLockRecType.DIRECT, DAVLockScope.EXCLUSIVE, DAVLockType.WRITE, lock.getExpirationDate()); }
public static StringBuffer generateReplayRequest( long highRevision, long lowRevision, boolean sendDeltas) { StringBuffer xmlBuffer = new StringBuffer(); SVNXMLUtil.addXMLHeader(xmlBuffer); SVNXMLUtil.openNamespaceDeclarationTag( SVNXMLUtil.SVN_NAMESPACE_PREFIX, "replay-report", SVN_NAMESPACES_LIST, SVNXMLUtil.PREFIX_MAP, xmlBuffer); SVNXMLUtil.openCDataTag( SVNXMLUtil.SVN_NAMESPACE_PREFIX, "revision", String.valueOf(highRevision), xmlBuffer); SVNXMLUtil.openCDataTag( SVNXMLUtil.SVN_NAMESPACE_PREFIX, "low-water-mark", String.valueOf(lowRevision), xmlBuffer); SVNXMLUtil.openCDataTag( SVNXMLUtil.SVN_NAMESPACE_PREFIX, "send-deltas", sendDeltas ? "1" : "0", xmlBuffer); SVNXMLUtil.addXMLFooter(SVNXMLUtil.SVN_NAMESPACE_PREFIX, "replay-report", xmlBuffer); return xmlBuffer; }
public static String getActiveLockXML(DAVLock lock) { StringBuffer buffer = new StringBuffer(); if (lock == null) { return ""; } if (lock.getRecType() == DAVLockRecType.INDIRECT_PARTIAL) { // TODO: add debugging message here? } SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.ACTIVE_LOCK.getName(), SVNXMLUtil.XML_STYLE_NORMAL, null, buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TYPE.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); if (lock.getType() == DAVLockType.WRITE) { SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.WRITE.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); } else { // TODO: internal error. log something? } SVNXMLUtil.closeXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TYPE.getName(), buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_SCOPE.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); if (lock.getScope() == DAVLockScope.EXCLUSIVE) { SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.EXCLUSIVE.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); } else if (lock.getScope() == DAVLockScope.SHARED) { SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.SHARED.getName(), SVNXMLUtil.XML_STYLE_SELF_CLOSING | SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); } else { // TODO: internal error. log something? } SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_SCOPE.getName(), buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.DEPTH.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); buffer.append( lock.getDepth() == DAVDepth.DEPTH_INFINITY ? DAVDepth.DEPTH_INFINITY.toString() : DAVDepth.DEPTH_ZERO.toString()); SVNXMLUtil.closeXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.DEPTH.getName(), buffer); if (lock.getOwner() != null) { buffer.append(lock.getOwner()); } SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TIMEOUT.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); if (lock.getTimeOutDate() == null) { buffer.append("Infinite"); } else { Date timeOutDate = lock.getTimeOutDate(); long now = System.currentTimeMillis(); long diff = timeOutDate.getTime() - now; buffer.append("Second-"); // TODO: I'm not sure if I clearly understand what we must send here, // have to test and review this later buffer.append(diff); } SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TIMEOUT.getName(), buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TOKEN.getName(), SVNXMLUtil.XML_STYLE_NORMAL, null, buffer); SVNXMLUtil.openXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.HREF.getName(), SVNXMLUtil.XML_STYLE_PROTECT_CDATA, null, buffer); buffer.append(lock.getLockToken()); SVNXMLUtil.closeXMLTag(SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.HREF.getName(), buffer); SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.LOCK_TOKEN.getName(), buffer); SVNXMLUtil.closeXMLTag( SVNXMLUtil.DAV_NAMESPACE_PREFIX, DAVElement.ACTIVE_LOCK.getName(), buffer); return buffer.toString(); }