本文整理汇总了Java中org.apache.ivy.util.Message类的典型用法代码示例。如果您正苦于以下问题:Java Message类的具体用法?Java Message怎么用?Java Message使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Message类属于org.apache.ivy.util包,在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: log
import org.apache.ivy.util.Message; //导入依赖的package包/类
@Override
public void log(String message, int level) {
message = "[Ivy] " + message.trim();
switch (level) {
case Message.MSG_ERR:
JkLog.error(message);
break;
case Message.MSG_WARN:
JkLog.warn(message);
break;
case Message.MSG_INFO:
JkLog.info(message);
break;
case Message.MSG_VERBOSE:
JkLog.trace(message);
break;
case Message.MSG_DEBUG:
JkLog.trace(message);
break;
default:
JkLog.info("[" + level + "] " + message);
}
}
示例2: checkStatusCode
import org.apache.ivy.util.Message; //导入依赖的package包/类
private boolean checkStatusCode(URL url, HttpURLConnection con) throws IOException {
final int status = con.getResponseCode();
if (status == HttpStatus.SC_OK) {
return true;
}
// IVY-1328: some servers return a 204 on a HEAD request
if ("HEAD".equals(con.getRequestMethod()) && (status == 204)) {
return true;
}
Message.debug("HTTP response status: " + status + " url=" + url);
if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) {
Message.warn("Your proxy requires authentication.");
} else if (String.valueOf(status).startsWith("4")) {
Message.verbose("CLIENT ERROR: " + con.getResponseMessage() + " url=" + url);
} else if (String.valueOf(status).startsWith("5")) {
Message.error("SERVER ERROR: " + con.getResponseMessage() + " url=" + url);
}
return false;
}
示例3: abortPublishTransaction
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Aborts a previously started publish transaction.
*
* @throws IOException If an error occurs aborting the publish transaction.
*/
public void abortPublishTransaction() throws IOException {
if (publishTransaction == null) {
Message.info("Transaction not created, nothing to abort");
return;
}
if (!publishTransaction.commitStarted()) {
Message.info("Commit transaction not started, nothing to abort");
return;
}
Message.info("Aborting transaction");
try {
publishTransaction.abort();
publishTransaction = null;
} catch (SVNException e) {
throw (IOException) new IOException().initCause(e);
}
}
示例4: get
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Handles a request to retrieve a file from the repository.
*
* @param source Path to the resource to retrieve, including the repository root.
* @param destination The location where the file should be retrieved to.
* @throws IOException If an error occurs retrieving the file.
*/
public void get(String source, File destination) throws IOException {
fireTransferInitiated(getResource(source), TransferEvent.REQUEST_GET);
String repositorySource = source;
if (!source.startsWith(repositoryRoot)) {
repositorySource = getRepositoryRoot() + source;
}
Message.debug("Getting file for user " + userName + " from " + repositorySource + " [revision="
+ svnRetrieveRevision + "] to " + destination.getAbsolutePath());
try {
SVNURL url = SVNURL.parseURIEncoded(repositorySource);
SVNRepository repository = getRepository(url, true);
repository.setLocation(url, false);
Resource resource = getResource(source);
fireTransferInitiated(resource, TransferEvent.REQUEST_GET);
SvnDao svnDAO = new SvnDao(repository);
svnDAO.getFile(url, destination, svnRetrieveRevision);
fireTransferCompleted(destination.length());
} catch (SVNException e) {
Message.error("Error retrieving" + repositorySource + " [revision=" + svnRetrieveRevision + "]");
throw (IOException) new IOException().initCause(e);
}
}
示例5: resolveResource
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Fetch the needed file information for a given file (size, last modification time) and report it back in a
* SvnResource.
*
* @param repositorySource Full path to resource in subversion (including host, protocol etc.)
* @return SvnResource filled with the needed informations
*/
protected SvnResource resolveResource(String repositorySource) {
Message.debug("Resolving resource for " + repositorySource + " [revision=" + svnRetrieveRevision + "]");
SvnResource result = null;
try {
SVNURL url = SVNURL.parseURIEncoded(repositorySource);
SVNRepository repository = getRepository(url, true);
SVNNodeKind nodeKind = repository.checkPath("", svnRetrieveRevision);
if (nodeKind == SVNNodeKind.NONE) {
// log this on debug, NOT error, see http://code.google.com/p/ivysvn/issues/detail?id=21
Message.debug("No resource found at " + repositorySource + ", returning default resource");
result = new SvnResource();
} else {
Message.debug("Resource found at " + repositorySource + ", returning resolved resource");
SVNDirEntry entry = repository.info("", svnRetrieveRevision);
result = new SvnResource(this, repositorySource, true, entry.getDate().getTime(), entry.getSize());
}
} catch (SVNException e) {
Message.error("Error resolving resource " + repositorySource + ", " + e.getMessage());
Message.debug("Exception is: " + getStackTrace(e)); // useful for debugging network issues
result = new SvnResource();
}
return result;
}
示例6: addPutOperation
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Adds an operation representing a file "put" to the transaction.
*
* @param source The file to put.
* @param destinationPath The full svn path to the file's location in svn.
* @param overwrite Whether an overwrite should be performed if the file already exists.
* @throws IOException If the file data cannot be read from disk or the file paths cannot be determined.
*/
public void addPutOperation(File source, String destinationPath, boolean overwrite) throws SVNException, IOException {
PutOperation operation = new PutOperation(source, destinationPath, overwrite);
String destinationFolderPath = operation.getFolderPath();
if (binaryDiff) { // publishing to intermediate binary diff location, override values set above
if (!operation.isOverwrite() && svnDAO.folderExists(operation.getFolderPath(), -1, true)) {
Message.info("Overwrite set to false, ignoring " + operation.getFilePath());
return;
}
destinationFolderPath = operation.determineBinaryDiffFolderPath(revision, binaryDiffFolderName);
overwrite = true; // force overwrite for binary diff
}
if (destinationFolderPath.startsWith("/")) {
destinationFolderPath = destinationFolderPath.substring(1);
}
String[] pathComponents = destinationFolderPath.split("/");
int pathIndex = 0;
DirectoryTree currentTree = publishTree; // start with the root tree
while (pathIndex < pathComponents.length) {
currentTree = currentTree.subDir(pathComponents[pathIndex]); // build up a tree for each subdir
pathIndex++;
}
currentTree.addPutOperation(operation); // add the put operation to the deepest level of the tree
}
示例7: commitTree
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Commits the contents of the passed DirectoryTree.
*
* @param tree Tree containing PutOperations to commit.
* @return The number of files committed. put operations.
* @throws SVNException If an error occurs performing any of the put operations.
* @throws IOException If an error occurs reading any file data.
*/
private int commitTree(DirectoryTree tree) throws SVNException, IOException {
int fileCount = 0;
if (tree.getParent() != null) {
if (svnDAO.folderExists(tree.getPath(), -1, true)) { // open dir to correct path in tree
commitEditor.openDir(tree.getPath(), -1);
} else {
Message.debug("Creating folder " + tree.getPath());
commitEditor.addDir(tree.getPath(), null, -1);
}
}
for (DirectoryTree subDir : tree.getSubDirectoryTrees()) {
fileCount += commitTree(subDir);
}
fileCount += performPutOperations(tree.getPutOperations()); // perform put operations at current open dir
if (tree.getParent() != null) {
commitEditor.closeDir(); // finished with this path, close dir
}
return fileCount;
}
示例8: prepareBinaryDiff
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Prepares the repository for the binary diffs needed for the passed tree.
*
* @param tree DirectoryTree to use to determine what binary diff actions are necessary.
* @param binaryDiffs A Map of folders which need to be copied in the binary diff transaction, values in the map will
* be added to or deleted by this method as necessary.
* @param processedFolders A set of folders which have already been processed.
* @throws SVNException If an error occurs checking existing folders or deleting removed folders.
*/
private void prepareBinaryDiff(DirectoryTree tree, Map<String, String> binaryDiffs, Set<String> processedFolders)
throws SVNException {
for (DirectoryTree subDir : tree.getSubDirectoryTrees()) { // depth-first calls to prepare binary diff
prepareBinaryDiff(subDir, binaryDiffs, processedFolders);
}
for (PutOperation operation : tree.getPutOperations()) {
String currentFolder = operation.getFolderPath();
if (!processedFolders.contains(currentFolder)) { // we haven't dealt with this folder yet
String binaryDiffFolderPath = operation.determineBinaryDiffFolderPath(revision, binaryDiffFolderName);
binaryDiffs.put(currentFolder, binaryDiffFolderPath); // schedule this to be processed later
if (svnDAO.folderExists(currentFolder, -1, true)) {
if (operation.isOverwrite()) {
// delete old release, we will copy over to release folder again in binary diff commit later
Message.info("Binary diff deleting " + currentFolder);
commitEditor.deleteEntry(currentFolder, -1);
} else {
Message.info("Overwrite set to false, ignoring copy to " + currentFolder);
binaryDiffs.remove(currentFolder);
}
}
}
processedFolders.add(currentFolder);
}
}
示例9: putFile
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Puts a file into Subversion, does update or add depending on whether file already exists or not. Folder containing
* file *must* already exist.
*
* @param editor An initialised commit editor.
* @param data File data as a byte array.
* @param destinationFolder Destination folder in svn.
* @param fileName File name.
* @param overwrite Whether existing file should be overwritten or not.
* @return true if File was updated or added, false if it was ignored (i.e. it already exists and overwrite was
* false).
* @throws SVNException If an error occurs putting the file into Subversion.
*/
public boolean putFile(ISVNEditor editor, byte[] data, String destinationFolder, String fileName, boolean overwrite)
throws SVNException {
String filePath = destinationFolder + "/" + fileName;
if (fileExists(filePath, -1)) { // updating existing file
if (overwrite) {
Message.debug("Updating file " + filePath);
editor.openFile(filePath, -1);
} else {
Message.info("Overwrite set to false, ignoring " + filePath);
return false;
}
} else { // creating new file
Message.debug("Adding file " + filePath);
editor.addFile(filePath, null, -1);
}
editor.applyTextDelta(filePath, null);
SVNDeltaGenerator deltaGenerator = new SVNDeltaGenerator();
String checksum = deltaGenerator.sendDelta(filePath, new ByteArrayInputStream(data), editor, true);
editor.closeFile(filePath, checksum);
return true;
}
示例10: getFile
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Gets a file from the repository.
*
* @param sourceURL The full path to the file, reachable via the read repository.
* @param destination The destination file.
* @param revision The subversion revision.
* @throws SVNException If an error occurs retrieving the file from Subversion.
* @throws IOException If an error occurs writing the file contents to disk.
*/
public void getFile(SVNURL sourceURL, File destination, long revision) throws SVNException, IOException {
readRepository.setLocation(sourceURL, false);
SVNNodeKind nodeKind = readRepository.checkPath("", revision);
SVNErrorMessage error = SvnUtils.checkNodeIsFile(nodeKind, sourceURL);
if (error != null) {
Message.error("Error retrieving" + sourceURL + " [revision=" + revision + "]");
throw new IOException(error.getMessage());
}
BufferedOutputStream output = null;
try {
output = new BufferedOutputStream(new FileOutputStream(destination));
readRepository.getFile("", revision, null, output);
} finally {
if (output != null) {
output.close();
}
}
}
示例11: initializeStreams
import org.apache.ivy.util.Message; //导入依赖的package包/类
private void initializeStreams() {
synchronized (document) {
if (!initialized) {
for (int i = 0; i < streams.length; i++) {
streams[i] = newMessageStream();
}
// install colors
Color color;
color = createColor(Display.getDefault(), PREF_CONSOLE_DEBUG_COLOR);
streams[Message.MSG_DEBUG].setColor(color);
color = createColor(Display.getDefault(), PREF_CONSOLE_VERBOSE_COLOR);
streams[Message.MSG_VERBOSE].setColor(color);
color = createColor(Display.getDefault(), PREF_CONSOLE_INFO_COLOR);
streams[Message.MSG_INFO].setColor(color);
color = createColor(Display.getDefault(), PREF_CONSOLE_WARN_COLOR);
streams[Message.MSG_WARN].setColor(color);
color = createColor(Display.getDefault(), PREF_CONSOLE_ERROR_COLOR);
streams[Message.MSG_ERR].setColor(color);
initialized = true;
}
}
}
示例12: lslToResource
import org.apache.ivy.util.Message; //导入依赖的package包/类
/**
* Parses a ls -l line and transforms it in a resource
*
* @param file ditto
* @param responseLine ditto
* @return Resource
*/
protected Resource lslToResource(String file, String responseLine) {
if (responseLine == null || responseLine.startsWith("ls")) {
return new BasicResource(file, false, 0, 0, false);
} else {
String[] parts = responseLine.split("\\s+");
if (parts.length != LS_PARTS_NUMBER) {
Message.debug("unrecognized ls format: " + responseLine);
return new BasicResource(file, false, 0, 0, false);
} else {
try {
long contentLength = Long.parseLong(parts[LS_SIZE_INDEX]);
String date = parts[LS_DATE_INDEX1] + " " + parts[LS_DATE_INDEX2] + " "
+ parts[LS_DATE_INDEX3] + " " + parts[LS_DATE_INDEX4];
return new BasicResource(file, true, contentLength, FORMAT.parse(date)
.getTime(), false);
} catch (Exception ex) {
Message.warn("impossible to parse server response: " + responseLine, ex);
return new BasicResource(file, false, 0, 0, false);
}
}
}
}
示例13: getModuleDescriptors
import org.apache.ivy.util.Message; //导入依赖的package包/类
private synchronized Map<ModuleDescriptor, File> getModuleDescriptors() {
if (md2IvyFile == null) {
md2IvyFile = new HashMap<>();
for (ResourceCollection resources : allResources) {
for (Resource resource : resources) {
File ivyFile = ((FileResource) resource).getFile();
try {
ModuleDescriptor md = ModuleDescriptorParserRegistry.getInstance()
.parseDescriptor(getParserSettings(), ivyFile.toURI().toURL(),
isValidate());
md2IvyFile.put(md, ivyFile);
Message.debug("Add " + md.getModuleRevisionId().getModuleId());
} catch (Exception ex) {
if (haltOnError) {
throw new BuildException("impossible to parse ivy file " + ivyFile
+ " exception=" + ex, ex);
} else {
Message.warn("impossible to parse ivy file " + ivyFile
+ " exception=" + ex.getMessage());
}
}
}
}
}
return md2IvyFile;
}
示例14: unlock
import org.apache.ivy.util.Message; //导入依赖的package包/类
public void unlock(File file) {
synchronized (this) {
LockData data = locks.get(file);
if (data == null) {
throw new IllegalArgumentException("file not previously locked: " + file);
}
try {
locks.remove(file);
data.l.release();
data.raf.close();
} catch (IOException e) {
Message.error("problem while releasing lock on " + file + ": " + e.getMessage());
}
}
}
示例15: initLatestStrategyFromSettings
import org.apache.ivy.util.Message; //导入依赖的package包/类
private void initLatestStrategyFromSettings() {
if (getSettings() != null) {
if (latestStrategyName != null && !"default".equals(latestStrategyName)) {
latestStrategy = getSettings().getLatestStrategy(latestStrategyName);
if (latestStrategy == null) {
throw new IllegalStateException("unknown latest strategy '"
+ latestStrategyName + "'");
}
} else {
latestStrategy = getSettings().getDefaultLatestStrategy();
Message.debug(getName() + ": no latest strategy defined: using default");
}
} else {
throw new IllegalStateException("no ivy instance found: "
+ "impossible to get a latest strategy without ivy instance");
}
}