protected void startElement(DAVElement parent, DAVElement element, Attributes attrs) throws SVNException { if (element == DAVElement.RESPONSE) { if (myCurrentResource != null) { invalidXML(); } myCurrentResource = new DAVProperties(); myCurrentProperties = new HashMap(); myStatusCode = 0; } else if (element == DAVElement.PROPSTAT) { myStatusCode = 0; } else if (element == DAVElement.COLLECTION) { myCurrentResource.setCollection(true); } else { myEncoding = attrs.getValue("encoding"); } }
public static DAVProperties getBaselineProperties(DAVConnection connection, DAVRepository repos, String path, long revision, DAVElement[] elements) throws SVNException { DAVProperties properties = null; String loppedPath = ""; properties = findStartingProperties(connection, repos, path); String vcc = properties.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); if (vcc == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The VCC property was not found on the resource"); SVNErrorManager.error(err); } loppedPath = properties.getLoppedPath(); String baselineRelativePath = properties.getPropertyValue(DAVElement.BASELINE_RELATIVE_PATH); if (baselineRelativePath == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The relative-path property was not found on the resource"); SVNErrorManager.error(err); } baselineRelativePath = SVNEncodingUtil.uriEncode(baselineRelativePath); baselineRelativePath = SVNPathUtil.append(baselineRelativePath, loppedPath); String label = null; if (revision < 0) { vcc = getPropertyValue(connection, vcc, null, DAVElement.CHECKED_IN); } else { label = Long.toString(revision); } properties = getResourceProperties(connection, vcc, label, elements); properties.setURL(baselineRelativePath); return properties; }
info.baselinePath = baselineProperties.getURL(); info.baselineBase = baselineProperties.getPropertyValue(DAVElement.BASELINE_COLLECTION); info.baseline = baselineProperties.getOriginalURL(); if (info.baselineBase == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "'DAV:baseline-collection' not present on the baseline resource"); String version = baselineProperties.getPropertyValue(DAVElement.VERSION_NAME); if (version == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "'DAV:version-name' not present on the baseline resource"); info.isDirectory = props != null && props.isCollection();
public static Map filterProperties(DAVProperties source, Map target) { target = target == null ? new HashMap() : target; for(Iterator props = source.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); String namespace = property.getNamespace(); if (namespace.equals(DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE)) { String name = property.getName(); // hack! if (name.startsWith("svk_")) { name = name.substring(0, "svk".length()) + ":" + name.substring("svk".length() + 1); } target.put(name, source.getPropertyValue(property)); } else if (namespace.equals(DAVElement.SVN_SVN_PROPERTY_NAMESPACE)) { target.put("svn:" + property.getName(), source.getPropertyValue(property)); } else if (property == DAVElement.CHECKED_IN) { target.put("svn:wc:ra_dav:version-url", source.getPropertyValue(property)); } } return target; } }
private SVNDirEntry createDirEntry(String fullPath, DAVProperties child) throws SVNException { String href = child.getURL(); href = SVNEncodingUtil.uriDecode(href); String name = SVNPathUtil.tail(href); // build direntry SVNNodeKind kind = SVNNodeKind.FILE; Object revisionStr = child.getPropertyValue(DAVElement.VERSION_NAME); long lastRevision = Long.parseLong(revisionStr.toString()); String sizeStr = child.getPropertyValue(DAVElement.GET_CONTENT_LENGTH); long size = sizeStr == null ? 0 : Long.parseLong(sizeStr); if (child.isCollection()) { kind = SVNNodeKind.DIR; } String author = child.getPropertyValue(DAVElement.CREATOR_DISPLAY_NAME); String dateStr = child.getPropertyValue(DAVElement.CREATION_DATE); Date date = dateStr != null ? SVNTimeUtil.parseDate(dateStr) : null; boolean hasProperties = false; for(Iterator props = child.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); if (DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE.equals(property.getNamespace()) || DAVElement.SVN_SVN_PROPERTY_NAMESPACE.equals(property.getNamespace())) { hasProperties = true; break; } } SVNURL url = getLocation().setPath(fullPath, true); return new SVNDirEntry(url, name, kind, size, hasProperties, lastRevision, date, author); } }
String value = null; if (element == DAVElement.RESPONSE) { if (myCurrentResource.getURL() == null) { invalidXML(); myResources.put(myCurrentResource.getURL(), myCurrentResource); myCurrentResource = null; return; String propValue = (String) myCurrentProperties.get(propName); if (myStatusCode == 200) { myCurrentResource.setProperty(propName, propValue); path = path.substring(0, path.length() - 1); myCurrentResource.setURL(path); return;
String url = (String) dirEnts.next(); DAVProperties child = (DAVProperties) dirEntsMap.get(url); String href = child.getURL(); String name = ""; if (parentPathSegments != SVNPathUtil.getSegmentsCount(href)) { Object revisionStr = child.getPropertyValue(DAVElement.VERSION_NAME); long lastRevision = Long.parseLong(revisionStr.toString()); String sizeStr = child.getPropertyValue(DAVElement.GET_CONTENT_LENGTH); long size = sizeStr == null ? 0 : Long.parseLong(sizeStr); if (child.isCollection()) { kind = SVNNodeKind.DIR; String author = child.getPropertyValue(DAVElement.CREATOR_DISPLAY_NAME); String dateStr = child.getPropertyValue(DAVElement.CREATION_DATE); Date date = dateStr != null ? SVNTimeUtil.parseDate(dateStr) : null; SVNURL childURL = getLocation().setPath(fullPath, true); if ("".equals(name)) { parent[0] = new SVNDirEntry(childURL, name, kind, size, false, lastRevision, date, author); parentVCC[0] = child.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); } else { childURL = childURL.appendPath(name, false); entries.add(new SVNDirEntry(childURL, name, kind, size, false, lastRevision, date, author)); vccs.add(child.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION));
props = getStartingProperties(connection, fullPath, null); if (props != null) { if (props.getPropertyValue(DAVElement.REPOSITORY_UUID) != null && repos != null) { repos.setRepositoryUUID(props.getPropertyValue(DAVElement.REPOSITORY_UUID)); props.setLoppedPath(loppedPath); if (props.getPropertyValue(DAVElement.REPOSITORY_UUID) != null && repos != null) { repos.setRepositoryUUID(props.getPropertyValue(DAVElement.REPOSITORY_UUID)); props.setLoppedPath(loppedPath);
public static String getVCCPath(DAVConnection connection, DAVRepository repository, String path) throws SVNException { DAVProperties properties = findStartingProperties(connection, repository, path); String vcc = properties.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); if (vcc == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The VCC property was not found on the resource"); SVNErrorManager.error(err); } return vcc; }
public static SVNProperties filterProperties(DAVProperties source, SVNProperties target) { target = target == null ? new SVNProperties() : target; for (Iterator props = source.getProperties().entrySet().iterator(); props.hasNext();) { Map.Entry entry = (Map.Entry) props.next(); DAVElement element = (DAVElement) entry.getKey(); SVNPropertyValue value = (SVNPropertyValue) entry.getValue(); String propertyName = getPropertyNameByElement(element); if (propertyName != null) { target.put(propertyName, value); } } return target; }
String url = (String) dirEnts.next(); DAVProperties child = (DAVProperties) dirEntsMap.get(url); String href = child.getURL(); if (parentPathSegments == SVNPathUtil.getSegmentsCount(href)) { continue; Object revisionStr = child.getPropertyValue(DAVElement.VERSION_NAME); long lastRevision = Long.parseLong(revisionStr.toString()); String sizeStr = child.getPropertyValue(DAVElement.GET_CONTENT_LENGTH); long size = sizeStr == null ? 0 : Long.parseLong(sizeStr); if (child.isCollection()) { kind = SVNNodeKind.DIR; String author = child.getPropertyValue(DAVElement.CREATOR_DISPLAY_NAME); String dateStr = child.getPropertyValue(DAVElement.CREATION_DATE); Date date = dateStr != null ? SVNTimeUtil.parseDate(dateStr) : null; boolean hasProperties = false; for(Iterator props = child.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); if (DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE.equals(property.getNamespace()) || DAVProperties dirProps = DAVUtil.getResourceProperties(myConnection, path, null, null); DAVUtil.filterProperties(dirProps, properties); for(Iterator props = dirProps.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); if (property == DAVElement.VERSION_NAME) { properties.put(SVNProperty.COMMITTED_REVISION, dirProps.getPropertyValue(property)); } else if (property == DAVElement.CREATOR_DISPLAY_NAME) { properties.put(SVNProperty.LAST_AUTHOR, dirProps.getPropertyValue(property));
if (myCurrentResource.getURL() == null) { invalidXML(); myResources.put(myCurrentResource.getURL(), myCurrentResource); myCurrentResource = null; return; SVNPropertyValue propValue = (SVNPropertyValue) entry.getValue(); if (myStatusCode == 200) { myCurrentResource.setProperty(propName, propValue); path = path.substring(0, path.length() - 1); myCurrentResource.setURL(path); return;
String url = (String) dirEnts.next(); DAVProperties child = (DAVProperties) dirEntsMap.get(url); String href = child.getURL(); String name = ""; if (parentPathSegments != SVNPathUtil.getSegmentsCount(href)) { Object revisionStr = child.getPropertyValue(DAVElement.VERSION_NAME); long lastRevision = -1; if (revisionStr != null) { final SVNPropertyValue sizeValue = child.getPropertyValue(DAVElement.GET_CONTENT_LENGTH); final String sizeValueString = SVNPropertyValue.getPropertyAsString(sizeValue); long size = 0; if (child.isCollection()) { kind = SVNNodeKind.DIR; SVNPropertyValue authorValue = child.getPropertyValue(DAVElement.CREATOR_DISPLAY_NAME); String author = authorValue == null ? null : authorValue.getString(); SVNPropertyValue dateValue = child.getPropertyValue(DAVElement.CREATION_DATE); Date date = dateValue != null ? SVNDate.parseDate(dateValue.getString()) : null; connection.fetchRepositoryRoot(this); parent[0] = new SVNDirEntry(childURL, repositoryRoot, name, kind, size, false, lastRevision, date, author); SVNPropertyValue vcc = child.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); parentVCC[0] = vcc == null ? null : vcc.getString(); } else {
public static SVNProperties filterProperties(DAVProperties source, SVNProperties target) { target = target == null ? new SVNProperties() : target; for (Iterator props = source.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); String namespace = property.getNamespace(); if (namespace.equals(DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE)) { String name = property.getName(); // hack! if (name.startsWith("svk_")) { name = name.substring(0, "svk".length()) + ":" + name.substring("svk".length() + 1); } target.put(name, source.getPropertyValue(property)); } else if (namespace.equals(DAVElement.SVN_SVN_PROPERTY_NAMESPACE)) { target.put("svn:" + property.getName(), source.getPropertyValue(property)); } else if (property == DAVElement.CHECKED_IN) { target.put("svn:wc:ra_dav:version-url", source.getPropertyValue(property)); } } return target; }
props = getStartingProperties(connection, fullPath, null); if (props != null) { if (props.getPropertyValue(DAVElement.REPOSITORY_UUID) != null && repos != null) { repos.setRepositoryUUID(props.getPropertyValue(DAVElement.REPOSITORY_UUID).getString()); props.setLoppedPath(loppedPath); if (props.getPropertyValue(DAVElement.REPOSITORY_UUID) != null && repos != null) { repos.setRepositoryUUID(props.getPropertyValue(DAVElement.REPOSITORY_UUID).getString()); if (props.getPropertyValue(DAVElement.BASELINE_RELATIVE_PATH) != null && repos != null) { String relativePath = props.getPropertyValue(DAVElement.BASELINE_RELATIVE_PATH).getString(); relativePath = SVNEncodingUtil.uriEncode(relativePath); String rootPath = fullPath.substring(0, fullPath.length() - relativePath.length()); repos.setRepositoryRoot(repos.getLocation().setPath(rootPath, true)); props.setLoppedPath(loppedPath);
public static String getVCCPath(DAVConnection connection, DAVRepository repository, String path) throws SVNException { DAVProperties properties = findStartingProperties(connection, repository, path); SVNPropertyValue vcc = properties.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); if (vcc == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The VCC property was not found on the resource"); SVNErrorManager.error(err, SVNLogType.NETWORK); } return vcc.getString(); }
public static SVNProperties filterProperties(DAVProperties source, SVNProperties target) { target = target == null ? new SVNProperties() : target; for (Iterator props = source.getProperties().entrySet().iterator(); props.hasNext();) { Map.Entry entry = (Map.Entry) props.next(); DAVElement element = (DAVElement) entry.getKey(); SVNPropertyValue value = (SVNPropertyValue) entry.getValue(); String propertyName = getPropertyNameByElement(element); if (propertyName != null) { target.put(propertyName, value); } } return target; }
private SVNDirEntry createDirEntry(String fullPath, DAVProperties child) throws SVNException { String href = child.getURL(); href = SVNEncodingUtil.uriDecode(href); Object revisionStr = child.getPropertyValue(DAVElement.VERSION_NAME); long lastRevision = -1; if (revisionStr != null) { final SVNPropertyValue sizeValue = child.getPropertyValue(DAVElement.GET_CONTENT_LENGTH); final String sizeValueString = SVNPropertyValue.getPropertyAsString(sizeValue); long size = 0; if (child.isCollection()) { kind = SVNNodeKind.DIR; SVNPropertyValue authorValue = child.getPropertyValue(DAVElement.CREATOR_DISPLAY_NAME); String author = authorValue == null ? null : authorValue.getString(); SVNPropertyValue dateValue = child.getPropertyValue(DAVElement.CREATION_DATE); Date date = dateValue != null ? SVNDate.parseDate(dateValue.getString()) : null; boolean hasProperties = false; for (Iterator props = child.getProperties().keySet().iterator(); props.hasNext();) { DAVElement property = (DAVElement) props.next(); if (DAVElement.SVN_CUSTOM_PROPERTY_NAMESPACE.equals(property.getNamespace()) ||
info.baselinePath = baselineProperties.getURL(); SVNPropertyValue baseValue = baselineProperties.getPropertyValue(DAVElement.BASELINE_COLLECTION); info.baselineBase = baseValue == null ? null : baseValue.getString(); info.baseline = baselineProperties.getOriginalURL(); if (info.baselineBase == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "'DAV:baseline-collection' not present on the baseline resource"); SVNPropertyValue version = baselineProperties.getPropertyValue(DAVElement.VERSION_NAME); if (version == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "'DAV:version-name' not present on the baseline resource"); info.isDirectory = props != null && props.isCollection();
public static DAVProperties getBaselineProperties(DAVConnection connection, DAVRepository repos, String path, long revision, DAVElement[] elements) throws SVNException { DAVProperties properties = null; String loppedPath = ""; properties = findStartingProperties(connection, repos, path); SVNPropertyValue vccValue = properties.getPropertyValue(DAVElement.VERSION_CONTROLLED_CONFIGURATION); if (vccValue == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The VCC property was not found on the resource"); SVNErrorManager.error(err, SVNLogType.NETWORK); } loppedPath = properties.getLoppedPath(); SVNPropertyValue baselineRelativePathValue = properties.getPropertyValue(DAVElement.BASELINE_RELATIVE_PATH); if (baselineRelativePathValue == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_DAV_REQUEST_FAILED, "The relative-path property was not found on the resource"); SVNErrorManager.error(err, SVNLogType.NETWORK); } String baselineRelativePath = SVNEncodingUtil.uriEncode(baselineRelativePathValue.getString()); baselineRelativePath = SVNPathUtil.append(baselineRelativePath, loppedPath); String label = null; String vcc = vccValue.getString(); if (revision < 0) { vcc = getPropertyValue(connection, vcc, null, DAVElement.CHECKED_IN); } else { label = Long.toString(revision); } properties = getResourceProperties(connection, vcc, label, elements); properties.setURL(baselineRelativePath); return properties; }