Java Code Examples for org.apache.ivy.util.Message#error()
The following examples show how to use
org.apache.ivy.util.Message#error() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IvyFollowRedirectUrlHandler.java From jeka with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: BasicURLHandler.java From ant-ivy with Apache License 2.0 | 6 votes |
private boolean checkStatusCode(URL url, HttpURLConnection con) throws IOException { 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; }
Example 3
Source File: HttpClientHandler.java From ant-ivy with Apache License 2.0 | 6 votes |
private boolean checkStatusCode(final String httpMethod, final URL sourceURL, final HttpResponse response) { final int status = response.getStatusLine().getStatusCode(); if (status == HttpStatus.SC_OK) { return true; } // IVY-1328: some servers return a 204 on a HEAD request if (HttpHead.METHOD_NAME.equals(httpMethod) && (status == 204)) { return true; } Message.debug("HTTP response status: " + status + " url=" + sourceURL); if (status == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED) { Message.warn("Your proxy requires authentication."); } else if (String.valueOf(status).startsWith("4")) { Message.verbose("CLIENT ERROR: " + response.getStatusLine().getReasonPhrase() + " url=" + sourceURL); } else if (String.valueOf(status).startsWith("5")) { Message.error("SERVER ERROR: " + response.getStatusLine().getReasonPhrase() + " url=" + sourceURL); } return false; }
Example 4
Source File: DefaultRepositoryCacheManager.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * Saves the information of which resolver was used to resolve a md, so that this info can be * retrieve later (even after a jvm restart) by getSavedArtResolverName(ModuleDescriptor md) * * @param md * the module descriptor resolved * @param metadataResolverName * metadata resolver name * @param artifactResolverName * artifact resolver name */ public void saveResolvers(ModuleDescriptor md, String metadataResolverName, String artifactResolverName) { ModuleRevisionId mrid = md.getResolvedModuleRevisionId(); if (!lockMetadataArtifact(mrid)) { Message.error("impossible to acquire lock for " + mrid); return; } try { PropertiesFile cdf = getCachedDataFile(md); cdf.setProperty("resolver", metadataResolverName); cdf.setProperty("artifact.resolver", artifactResolverName); cdf.save(); } finally { unlockMetadataArtifact(mrid); } }
Example 5
Source File: DefaultRepositoryCacheManager.java From ant-ivy with Apache License 2.0 | 6 votes |
public void saveResolvedRevision(String resolverName, ModuleRevisionId mrid, String revision) { if (!lockMetadataArtifact(mrid)) { Message.error("impossible to acquire lock for " + mrid); return; } try { PropertiesFile cachedResolvedRevision; if (resolverName == null) { cachedResolvedRevision = getCachedDataFile(mrid); } else { cachedResolvedRevision = getCachedDataFile(resolverName, mrid); } cachedResolvedRevision.setProperty("resolved.time", String.valueOf(System.currentTimeMillis())); cachedResolvedRevision.setProperty("resolved.revision", revision); if (resolverName != null) { cachedResolvedRevision.setProperty("resolver", resolverName); } cachedResolvedRevision.save(); } finally { unlockMetadataArtifact(mrid); } }
Example 6
Source File: FileBasedLockStrategy.java From ant-ivy with Apache License 2.0 | 6 votes |
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()); } } }
Example 7
Source File: PomModuleDescriptorBuilder.java From ant-ivy with Apache License 2.0 | 6 votes |
private static List<ModuleId> getDependencyMgtExclusions(ModuleDescriptor descriptor, String groupId, String artifactId) { if (descriptor instanceof PomModuleDescriptor) { PomDependencyMgt dependencyMgt = ((PomModuleDescriptor) descriptor) .getDependencyManagementMap().get(ModuleId.newInstance(groupId, artifactId)); if (dependencyMgt != null) { return dependencyMgt.getExcludedModules(); } } String exclusionPrefix = getDependencyMgtExtraInfoPrefixForExclusion(groupId, artifactId); List<ModuleId> exclusionIds = new LinkedList<>(); for (ExtraInfoHolder extraInfoHolder : descriptor.getExtraInfos()) { String key = extraInfoHolder.getName(); if (key.startsWith(exclusionPrefix)) { String fullExclusion = extraInfoHolder.getContent(); String[] exclusionParts = fullExclusion.split(EXTRA_INFO_DELIMITER); if (exclusionParts.length != 2) { Message.error(WRONG_NUMBER_OF_PARTS_MSG + exclusionParts.length + " : " + fullExclusion); continue; } exclusionIds.add(ModuleId.newInstance(exclusionParts[0], exclusionParts[1])); } } return exclusionIds; }
Example 8
Source File: RegexpConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
public void setRegexp(String regexp) { pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher("abcdef"); if (matcher.groupCount() != 1) { String message = "Pattern does not contain ONE (capturing group): '" + pattern + "'"; Message.error(message); throw new IllegalArgumentException(message); } }
Example 9
Source File: LatestConflictManager.java From ant-ivy with Apache License 2.0 | 5 votes |
public LatestStrategy getStrategy() { if (strategy == null) { if (strategyName != null) { strategy = getSettings().getLatestStrategy(strategyName); if (strategy == null) { Message.error("unknown latest strategy: " + strategyName); strategy = getSettings().getDefaultLatestStrategy(); } } else { strategy = getSettings().getDefaultLatestStrategy(); } } return strategy; }
Example 10
Source File: PackagerResolver.java From ant-ivy with Apache License 2.0 | 5 votes |
public void setDescriptor(String rule) { if (DESCRIPTOR_OPTIONAL.equals(rule)) { Message.error("descriptor=\"" + DESCRIPTOR_OPTIONAL + "\" not supported by resolver " + this); return; } super.setDescriptor(rule); }
Example 11
Source File: AbstractSshBasedRepository.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Just check the uri for sanity * * @param source * String of the uri * @return URI object of the String or null */ private URI parseURI(String source) { try { URI uri = new URI(source); if (uri.getScheme() != null && !uri.getScheme().toLowerCase(Locale.US) .equals(getRepositoryScheme().toLowerCase(Locale.US))) { throw new URISyntaxException(source, "Wrong scheme in URI. Expected " + getRepositoryScheme() + " as scheme!"); } if (uri.getHost() == null && getHost() == null) { throw new URISyntaxException(source, "Missing host in URI or in resolver"); } if (uri.getPath() == null) { throw new URISyntaxException(source, "Missing path in URI"); } // if (uri.getUserInfo() == null && getUser() == null) { // throw new URISyntaxException(source, "Missing username in URI or in resolver"); // } return uri; } catch (URISyntaxException e) { Message.error(e.getMessage()); Message.error("The uri '" + source + "' is in the wrong format."); Message.error("Please use " + getRepositoryScheme() + "://user:pass@hostname/path/to/repository"); return null; } }
Example 12
Source File: IvySettings.java From ant-ivy with Apache License 2.0 | 5 votes |
public synchronized DependencyResolver getResolver(String resolverName) { DependencyResolver r = getDictatorResolver(); if (r != null) { return r; } DependencyResolver resolver = resolversMap.get(resolverName); if (resolver == null) { Message.error("unknown resolver " + resolverName); } else if (workspaceResolver != null && !(resolver instanceof WorkspaceChainResolver)) { resolver = new WorkspaceChainResolver(this, resolver, workspaceResolver); resolversMap.put(resolver.getName(), resolver); resolversMap.put(resolverName, resolver); } return resolver; }
Example 13
Source File: BundleRepoDescriptor.java From ant-ivy with Apache License 2.0 | 5 votes |
public void populate(Iterator<ManifestAndLocation> it) { while (it.hasNext()) { ManifestAndLocation manifestAndLocation = it.next(); try { BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation .getManifest()); bundleInfo .addArtifact(new BundleArtifact(false, manifestAndLocation.getUri(), null)); addBundle(bundleInfo); } catch (ParseException e) { Message.error("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage()); } } }
Example 14
Source File: IvyTask.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * Called when task is about to finish Should clean up all state related information (stacks for * example) */ protected void finalizeTask() { if (!IvyContext.getContext().pop(ANT_PROJECT_CONTEXT_KEY, getProject())) { Message.error("ANT project popped from stack not equals current! Ignoring"); } IvyContext.popContext(); }
Example 15
Source File: PomModuleDescriptorParser.java From ant-ivy with Apache License 2.0 | 4 votes |
private ParseException newParserException(Exception e) { Message.error(e.getMessage()); ParseException pe = new ParseException(e.getMessage(), 0); pe.initCause(e); return pe; }
Example 16
Source File: CacheResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
@Override public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data) throws ParseException { clearIvyAttempts(); ModuleRevisionId mrid = dd.getDependencyRevisionId(); // check revision ResolvedModuleRevision rmr = getRepositoryCacheManager().findModuleInCache(dd, mrid, getCacheOptions(data), null); if (rmr != null) { Message.verbose("\t" + getName() + ": revision in cache: " + mrid); return rmr; } else if (!getSettings().getVersionMatcher().isDynamic(mrid)) { Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid); return null; } else { ensureConfigured(); ResolvedResource ivyRef = findIvyFileRef(dd, data); if (ivyRef != null) { Message.verbose("\t" + getName() + ": found ivy file in cache for " + mrid); Message.verbose("\t\t=> " + ivyRef); ModuleRevisionId resolvedMrid = ModuleRevisionId.newInstance(mrid, ivyRef.getRevision()); IvyNode node = data.getNode(resolvedMrid); if (node != null && node.getModuleRevision() != null) { // this revision has already be resolved : return it Message.verbose("\t" + getName() + ": revision already resolved: " + resolvedMrid); return node.getModuleRevision(); } rmr = getRepositoryCacheManager().findModuleInCache( dd.clone(ModuleRevisionId.newInstance(dd.getDependencyRevisionId(), ivyRef.getRevision())), dd.getDependencyRevisionId(), getCacheOptions(data), null); if (rmr != null) { Message.verbose("\t" + getName() + ": revision in cache: " + resolvedMrid); return rmr; } else { Message.error("\t" + getName() + ": inconsistent cache: clean it and resolve again"); return null; } } else { Message.verbose("\t" + getName() + ": no ivy file in cache found for " + mrid); return null; } } }
Example 17
Source File: BasicResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
private void checkDescriptorConsistency(ModuleRevisionId mrid, ModuleDescriptor md, ResolvedResource ivyRef) throws ParseException { boolean ok = true; StringBuilder errors = new StringBuilder(); if (!mrid.getOrganisation().equals(md.getModuleRevisionId().getOrganisation())) { Message.error(String.format("\t%s: bad organisation found in %s: expected='%s' found='%s'", getName(), ivyRef.getResource(), mrid.getOrganisation(), md.getModuleRevisionId().getOrganisation())); errors.append("bad organisation: expected='").append(mrid.getOrganisation()) .append("' found='").append(md.getModuleRevisionId().getOrganisation()).append("'; "); ok = false; } if (!mrid.getName().equals(md.getModuleRevisionId().getName())) { Message.error(String.format("\t%s: bad module name found in %s: expected='%s found='%s'", getName(), ivyRef.getResource(), mrid.getName(), md.getModuleRevisionId().getName())); errors.append("bad module name: expected='").append(mrid.getName()).append("' found='") .append(md.getModuleRevisionId().getName()).append("'; "); ok = false; } if (mrid.getBranch() != null && !mrid.getBranch().equals(md.getModuleRevisionId().getBranch())) { Message.error(String.format("\t%s: bad branch name found in %s: expected='%s found='%s'", getName(), ivyRef.getResource(), mrid.getBranch(), md.getModuleRevisionId().getBranch())); errors.append("bad branch name: expected='").append(mrid.getBranch()).append("' found='") .append(md.getModuleRevisionId().getBranch()).append("'; "); ok = false; } if (ivyRef.getRevision() != null && !ivyRef.getRevision().startsWith("working@") && !mrid.getRevision().equals(md.getModuleRevisionId().getRevision())) { ModuleRevisionId expectedMrid = ModuleRevisionId.newInstance(mrid, mrid.getRevision()); if (!getSettings().getVersionMatcher().accept(expectedMrid, md)) { Message.error(String.format("\t%s: bad revision found in %s: expected='%s found='%s'", getName(), ivyRef.getResource(), ivyRef.getRevision(), md.getModuleRevisionId().getRevision())); errors.append("bad revision: expected='").append(ivyRef.getRevision()) .append("' found='").append(md.getModuleRevisionId().getRevision()).append("'; "); ok = false; } } if (!getSettings().getStatusManager().isStatus(md.getStatus())) { Message.error(String.format("\t%s: bad status found in %s: '%s'", getName(), ivyRef.getResource(), md.getStatus())); errors.append("bad status: '").append(md.getStatus()).append("'; "); ok = false; } for (Map.Entry<String, String> extra : mrid.getExtraAttributes().entrySet()) { if (extra.getValue() != null && !extra.getValue().equals(md.getExtraAttribute(extra.getKey()))) { String errorMsg = String.format("bad %s found in %s: expected='%s' found='%s'", extra.getKey(), ivyRef.getResource(), extra.getValue(), md.getExtraAttribute(extra.getKey())); Message.error("\t" + getName() + ": " + errorMsg); errors.append(errorMsg).append(";"); ok = false; } } if (!ok) { throw new ParseException("inconsistent module descriptor file found in '" + ivyRef.getResource() + "': " + errors, 0); } }
Example 18
Source File: PackagerResolver.java From ant-ivy with Apache License 2.0 | 4 votes |
public void setAllownomd(boolean b) { Message.error("allownomd not supported by resolver " + this); }
Example 19
Source File: DefaultRepositoryCacheManager.java From ant-ivy with Apache License 2.0 | 4 votes |
/** * Called by doFindModuleInCache to lookup the dynamic {@code mrid} in the ivycache's ivydata * file. */ private String getResolvedRevision(String expectedResolver, ModuleRevisionId mrid, CacheMetadataOptions options) { if (!lockMetadataArtifact(mrid)) { Message.error("impossible to acquire lock for " + mrid); return null; } try { if (options.isForce()) { Message.verbose("refresh mode: no check for cached resolved revision for " + mrid); return null; } // If a resolver is asking for its specific dynamic revision, avoid looking at a different one PropertiesFile cachedResolvedRevision; if (expectedResolver != null) { cachedResolvedRevision = getCachedDataFile(expectedResolver, mrid); } else { cachedResolvedRevision = getCachedDataFile(mrid); } String resolvedRevision = cachedResolvedRevision.getProperty("resolved.revision"); if (resolvedRevision == null) { Message.verbose(getName() + ": no cached resolved revision for " + mrid); return null; } String resolvedTime = cachedResolvedRevision.getProperty("resolved.time"); if (resolvedTime == null) { Message.verbose(getName() + ": inconsistent or old cache: no cached resolved time for " + mrid); saveResolvedRevision(expectedResolver, mrid, resolvedRevision); return resolvedRevision; } if (options.isCheckTTL()) { long expiration = Long.parseLong(resolvedTime) + getTTL(mrid); // negative expiration means that Long.MAX_VALUE has been exceeded if (expiration > 0 && System.currentTimeMillis() > expiration) { Message.verbose(getName() + ": cached resolved revision expired for " + mrid); return null; } } return resolvedRevision; } finally { unlockMetadataArtifact(mrid); } }