private static void handleInconsistentEOL(SVNException svne, String path) throws SVNException { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.IO_INCONSISTENT_EOL) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.ILLEGAL_TARGET, "File ''{0}'' has inconsistent newlines", path); SVNErrorManager.error(error, SVNLogType.DEFAULT); } else { throw svne; } } }
private void lookupToken(String token, boolean isFile) throws SVNException { Boolean tokenType = (Boolean) myTokens.get(token); if (tokenType == null || tokenType != Boolean.valueOf(isFile)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Invalid file or dir token during edit"); SVNErrorManager.error(err, SVNLogType.NETWORK); } }
protected void endElement(DAVElement parent, DAVElement element, StringBuffer cdata) throws SVNException { if (element == DAVElement.VERSION_NAME && cdata != null) { try { myRevisionNumber = Long.parseLong(cdata.toString()); } catch (NumberFormatException nfe) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_DAV_MALFORMED_DATA, nfe), SVNLogType.NETWORK); } } }
private static SVNAdminAreaFactory getAdminAreaFactory(int wcFormat) throws SVNException { for (Iterator<SVNAdminAreaFactory> ourFactoriesIter = ourFactories.iterator(); ourFactoriesIter.hasNext();) { SVNAdminAreaFactory nextFactory = ourFactoriesIter.next(); if (nextFactory.getSupportedVersion() == wcFormat) { return nextFactory; } } SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.WC_UNSUPPORTED_FORMAT), SVNLogType.DEFAULT); return null; }
@Override public void validateLocks() throws SVNException { try { final VcsRevision revision = repo.getLatestRevision(); final Iterator<Map.Entry<String, LockDesc>> iter = locks.entrySet().iterator(); while (iter.hasNext()) { final Map.Entry<String, LockDesc> entry = iter.next(); final LockDesc item = entry.getValue(); final VcsFile file = revision.getFile(item.getPath()); if ((file == null) || file.isDirectory() || (!item.getHash().equals(file.getContentHash()))) { iter.remove(); } } } catch (IOException e) { throw new SVNException(SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e)); } }
protected String checkRevPropTarget(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } return (String) targets.iterator().next(); }
private void openRepository() throws SVNException { try { openRepositoryRoot(); } catch (SVNException svne) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_LOCAL_REPOS_OPEN_FAILED, "Unable to open repository ''{0}''", getLocation().toDecodedString()); err.setChildErrorMessage(svne.getErrorMessage()); SVNErrorManager.error(err.wrap("Unable to open an ra_local session to URL"), SVNLogType.FSFS); } }
private void fixError(String path, SVNException e, SVNNodeKind kind) throws SVNException { SVNErrorMessage err = e.getErrorMessage(); if (err.getErrorCode() == SVNErrorCode.FS_NOT_FOUND || err.getErrorCode() == SVNErrorCode.RA_DAV_PATH_NOT_FOUND) { err = SVNErrorMessage.create(SVNErrorCode.WC_NOT_UP_TO_DATE, kind == SVNNodeKind.DIR ? "Directory ''{0}'' is out of date" : "File ''{0}'' is out of date", path); throw new SVNException(err); } throw e; }
public long getDatedRevision(Date date) throws SVNException { date = date == null ? new Date(System.currentTimeMillis()) : date; DAVDateRevisionHandler handler = new DAVDateRevisionHandler(); StringBuffer request = DAVDateRevisionHandler.generateDateRevisionRequest(null, date); try { openConnection(); DAVConnection connection = getConnection(); String path = getReportTarget(connection); HTTPStatus status = connection.doReport(path, request, handler); if (status.getError() != null) { if (status.getError().getErrorCode() == SVNErrorCode.UNSUPPORTED_FEATURE) { SVNErrorMessage err2 = SVNErrorMessage.create(status.getError().getErrorCode(), "Server does not support date-based operations"); SVNErrorManager.error(err2, status.getError(), SVNLogType.NETWORK); } SVNErrorManager.error(status.getError(), SVNLogType.NETWORK); } } finally { closeConnection(); } return handler.getRevisionNumber(); }
public static void error(SVNErrorMessage err, Level logLevel, SVNLogType logType) throws SVNException { if (err == null) { err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN); } SVNDebugLog.getDefaultLog().log(logType, err.getFullMessage(), logLevel); if (err.getErrorCode() == SVNErrorCode.CANCELLED) { throw new SVNCancelException(err); } else if (err.getErrorCode().isAuthentication()) { throw new SVNAuthenticationException(err); } else { throw new SVNException(err); } }
private void validateRules() throws SVNException { if (myRules != null) { for (Iterator iterator = myRules.keySet().iterator(); iterator.hasNext();) { String matchString = (String) iterator.next(); if (matchString.startsWith("@")) { if (!getGroups().keySet().contains(matchString.substring("@".length()))) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_DAV_INVALID_CONFIG_VALUE, "An authz rule refers to group ''{0}'', which is undefined.", matchString), SVNLogType.NETWORK); } } else if (matchString.startsWith("&")) { if (!getAliases().keySet().contains(matchString.substring("&".length()))) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.RA_DAV_INVALID_CONFIG_VALUE, "An authz rule refers to alias ''{0}'', which is undefined.", matchString), SVNLogType.NETWORK); } } } } }
private void handleUnsupportedCommand(SVNException e, String message) throws SVNException { if (e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_SVN_UNKNOWN_CMD) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_NOT_IMPLEMENTED, message); SVNErrorManager.error(err, e.getErrorMessage(), SVNLogType.NETWORK); } throw e; }
private void lookupToken(String token, boolean isFile) throws SVNException { Boolean tokenType = (Boolean) myTokens.get(token); if (tokenType == null || tokenType != Boolean.valueOf(isFile)) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Invalid file or dir token during edit"); SVNErrorManager.error(err, SVNLogType.NETWORK); } }
protected String checkRevPropTarget(SVNRevision revision, Collection targets) throws SVNException { if (revision != SVNRevision.HEAD && revision.getDate() == null && revision.getNumber() < 0) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Must specify revision as a number, a date or 'HEAD' when operating on revision property"); SVNErrorManager.error(err, SVNLogType.CLIENT); } if (targets.size() != 1) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR, "Wrong number of targets specified"); SVNErrorManager.error(err, SVNLogType.CLIENT); } return (String) targets.iterator().next(); }
private void openRepository() throws SVNException { try { openRepositoryRoot(); } catch (SVNException svne) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_LOCAL_REPOS_OPEN_FAILED, "Unable to open repository ''{0}''", getLocation().toDecodedString()); err.setChildErrorMessage(svne.getErrorMessage()); SVNErrorManager.error(err.wrap("Unable to open an ra_local session to URL"), SVNLogType.FSFS); } }
private void fixError(String path, SVNException e, SVNNodeKind kind) throws SVNException { SVNErrorMessage err = e.getErrorMessage(); if (err.getErrorCode() == SVNErrorCode.FS_NOT_FOUND || err.getErrorCode() == SVNErrorCode.RA_DAV_PATH_NOT_FOUND) { err = SVNErrorMessage.create(SVNErrorCode.WC_NOT_UP_TO_DATE, kind == SVNNodeKind.DIR ? "Directory ''{0}'' is out of date" : "File ''{0}'' is out of date", path); throw new SVNException(err); } throw e; }
public long getDatedRevision(Date date) throws SVNException { date = date == null ? new Date(System.currentTimeMillis()) : date; DAVDateRevisionHandler handler = new DAVDateRevisionHandler(); StringBuffer request = DAVDateRevisionHandler.generateDateRevisionRequest(null, date); try { openConnection(); String path = getLocation().getURIEncodedPath(); path = DAVUtil.getVCCPath(myConnection, this, path); HTTPStatus status = myConnection.doReport(path, request, handler); if (status.getError() != null) { if (status.getError().getErrorCode() == SVNErrorCode.UNSUPPORTED_FEATURE) { SVNErrorMessage err2 = SVNErrorMessage.create(status.getError().getErrorCode(), "Server does not support date-based operations"); SVNErrorManager.error(err2, status.getError()); } SVNErrorManager.error(status.getError()); } } finally { closeConnection(); } return handler.getRevisionNumber(); }
public static void error(SVNErrorMessage err, Level logLevel, SVNLogType logType) throws SVNException { if (err == null) { err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN); } SVNDebugLog.getDefaultLog().log(logType, err.getFullMessage(), logLevel); if (err.getErrorCode() == SVNErrorCode.CANCELLED) { throw new SVNCancelException(err); } else if (err.getErrorCode().isAuthentication()) { throw new SVNAuthenticationException(err); } else { throw new SVNException(err); } }
public static boolean isSchemeSupportedByServer(String scheme, Collection<String> authHeaderValues) throws SVNException { if (authHeaderValues == null) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "Missing HTTP authorization method"); SVNErrorManager.error(err, SVNLogType.NETWORK); } String authHeader = null; for (Iterator<String> authSchemes = authHeaderValues.iterator(); authSchemes.hasNext();) { authHeader = authSchemes.next(); String source = authHeader.trim(); int index = source.indexOf(' '); if (index <= 0) { index = source.length(); } String method = source.substring(0, index); if (method.equalsIgnoreCase(scheme)) { return true; } } return false; }