{
try
{
URL rootURL = XMLMetadataHelper.getURL(URLUtil.toURL(getMetaDir(sProject)), true);
URL baseURL = null;
XMLMetadataHelper helper = new XMLMetadataHelper(rootURL, null, null, null);
Element descriptorElement = helper.getDescriptorElement(true);
String sRevision = descriptorElement.getAttribute(REVISION_ATTR);
String sVersion = descriptorElement.getAttribute(VERSION_ATTR);
String sBaseJarName = null;
if (!descriptorElement.hasAttribute(BASE_NAMESPACE_ATTR) || sProject.equals(".tmp"))
{
if (m_sBaseJarProperty != null)
{
getProject().setProperty(m_sBaseJarProperty, "");
}
if (m_sBaseProjectProperty != null)
{
getProject().setProperty(m_sBaseProjectProperty, "");
}
if (m_sBasePathProperty != null)
{
getProject().setProperty(m_sBasePathProperty, "");
}
}
else
{
//Parse the namespace URL to retrieve the base project name.
String sBaseNamespace = descriptorElement.getAttribute(BASE_NAMESPACE_ATTR);
String sBaseProject = sBaseNamespace.substring(sBaseNamespace.lastIndexOf('/') + 1);
String sBaseVersion = descriptorElement.getAttribute(BASE_VERSION_ATTR);
String sBaseChecksum = descriptorElement.getAttribute(BASE_CHECKSUM_ATTR);
long lSearchTime, lStartTime = 0;
if (m_bProfileEnabled)
{
lStartTime = System.currentTimeMillis();
}
log("Searching for base repository '" + sBaseProject + "' with checksum " + sBaseChecksum);
sBaseJarName = getPublishedJARName(sBaseProject, sBaseChecksum);
if (m_bProfileEnabled)
{
lSearchTime = System.currentTimeMillis() - lStartTime;
log(" Search complete (" + lSearchTime + " ms).");
}
if (sBaseJarName == null)
{
throw new BuildException("Missing base repository '" + sBaseProject + "' with version " +
sBaseVersion + " and checksum " + sBaseChecksum);
}
if (m_sBaseJarProperty != null)
{
getProject().setProperty(m_sBaseJarProperty, sBaseJarName);
}
if (m_sBaseProjectProperty != null)
{
getProject().setProperty(m_sBaseProjectProperty, sBaseProject);
}
String sBaseRepositoryPath = XMLMetadataHelper.getRepositoryPath(sBaseNamespace);
if (m_sBasePathProperty != null)
{
getProject().setProperty(m_sBasePathProperty, sBaseRepositoryPath);
}
baseURL = getMetaFolderURL(sBaseJarName, sBaseRepositoryPath);
}
String sChecksum = null;
try
{
helper = new XMLMetadataHelper(rootURL, baseURL, null, null);
sChecksum = helper.getChecksum(true);
}
catch (MetadataException e)
{
if (baseURL != null)
{
// base may be old-style repository, rooted at /nexj/meta
if (m_sBasePathProperty != null)
{
getProject().setProperty(m_sBasePathProperty, "nexj/meta");
}
baseURL = getMetaFolderURL(sBaseJarName, "nexj/meta/");
helper = new XMLMetadataHelper(rootURL, baseURL, null, null);
sChecksum = helper.getChecksum(true);
}
else
{
throw e;
}