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); } }
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; }
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(); }
public void run() throws SVNException { List targets = getSVNEnvironment().combineTargets(getSVNEnvironment().getTargets(), true); if (targets.isEmpty()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT); } SVNWCClient client = getSVNEnvironment().getClientManager().getWCClient(); if (!getSVNEnvironment().isQuiet()) { client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment())); } SVNDepth depth = getSVNEnvironment().getDepth(); if (depth == SVNDepth.UNKNOWN) { depth = SVNDepth.EMPTY; } for (Iterator ts = targets.iterator(); ts.hasNext();) { String targetName = (String) ts.next(); SVNPath target = new SVNPath(targetName); if (target.isFile()) { try { client.doResolve(target.getFile(), depth, SVNConflictChoice.MERGED); } catch (SVNException e) { SVNErrorMessage err = e.getErrorMessage(); getSVNEnvironment().handleWarning(err, new SVNErrorCode[] {err.getErrorCode()}, getSVNEnvironment().isQuiet()); } } } }
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); } }
public void handleError(File path, SVNErrorMessage error) throws SVNException { while (error.hasChildErrorMessage()) { error = error.getChildErrorMessage(); } if (error.getErrorCode() == SVNErrorCode.WC_PATH_NOT_FOUND || error.getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) { return; } SVNErrorManager.error(error, SVNLogType.DEFAULT); }
private void createDBLogsLock(File dstPath) throws SVNException { try { SVNFileUtil.createFile(new File(dstPath, FSFS.DB_LOGS_LOCK_FILE), FSFS.PRE_12_COMPAT_UNNEEDED_FILE_CONTENTS, "US-ASCII"); } catch (SVNException svne) { SVNErrorMessage err = svne.getErrorMessage().wrap("Creating db logs lock file"); SVNErrorManager.error(err, SVNLogType.FSFS); } }
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 FSNodeHistory getNodeHistory(FSRevisionRoot root, String path) throws SVNException { FSRevisionNode node = null; SVNNodeKind kind = null; try { node = root.openPath(path, true, false).getRevNode(); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_NOT_FOUND) { kind = SVNNodeKind.NONE; } throw svne; } kind = node.getType(); if (kind == SVNNodeKind.NONE) { SVNErrorManager.error(FSErrors.errorNotFound(root, path)); } return new FSNodeHistory(new SVNLocationEntry(root.getRevision(), path), false, new SVNLocationEntry(FSRepository.SVN_INVALID_REVNUM, null)); }
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(); }
public void run() throws SVNException { List targets = getSVNEnvironment().combineTargets(getSVNEnvironment().getTargets(), true); if (targets.isEmpty()) { SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT); } SVNWCClient client = getSVNEnvironment().getClientManager().getWCClient(); if (!getSVNEnvironment().isQuiet()) { client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment())); } SVNDepth depth = getSVNEnvironment().getDepth(); if (depth == SVNDepth.UNKNOWN) { depth = SVNDepth.EMPTY; } for (Iterator ts = targets.iterator(); ts.hasNext();) { String targetName = (String) ts.next(); SVNPath target = new SVNPath(targetName); if (target.isFile()) { try { client.doResolve(target.getFile(), depth, SVNConflictChoice.MERGED); } catch (SVNException e) { SVNErrorMessage err = e.getErrorMessage(); getSVNEnvironment().handleWarning(err, new SVNErrorCode[] {err.getErrorCode()}, getSVNEnvironment().isQuiet()); } } } }
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); } }
public void handleError(File path, SVNErrorMessage error) throws SVNException { while (error.hasChildErrorMessage()) { error = error.getChildErrorMessage(); } if (error.getErrorCode() == SVNErrorCode.WC_PATH_NOT_FOUND || error.getErrorCode() == SVNErrorCode.WC_NOT_LOCKED) { return; } SVNErrorManager.error(error, SVNLogType.DEFAULT); } }
private void createDBLock(File dstPath) throws SVNException { try { SVNFileUtil.createFile(new File(dstPath, FSFS.DB_LOCK_FILE), FSFS.PRE_12_COMPAT_UNNEEDED_FILE_CONTENTS, "US-ASCII"); } catch (SVNException svne) { SVNErrorMessage err = svne.getErrorMessage().wrap("Creating db lock file"); SVNErrorManager.error(err, SVNLogType.FSFS); } }
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(); }