}
Iterator repositoriesIterator = cachedRepositories.iterator();
while (repositoriesIterator.hasNext())
{
RepositoryVO repositoryVO = (RepositoryVO) repositoriesIterator.next();
String fullDnsNames = repositoryVO.getDnsName();
String workingPath = null;
int workingPathIndex = fullDnsNames.indexOf("workingPath=");
if(workingPathIndex > -1)
{
workingPath = fullDnsNames.substring(workingPathIndex + 12);
int workingPathEndIndex = workingPath.indexOf(",");
if(workingPathEndIndex > -1)
workingPath = workingPath.substring(0, workingPathEndIndex);
}
String livePath = null;
int livePathIndex = fullDnsNames.indexOf("path=");
if(livePathIndex > -1)
{
livePath = fullDnsNames.substring(livePathIndex + 5);
int livePathEndIndex = livePath.indexOf(",");
if(livePathEndIndex > -1)
livePath = livePath.substring(0, livePathEndIndex);
}
if(CmsPropertyHandler.getOperatingMode().equals("0"))
{
String workingPathAlternative1 = workingPath;
if(workingPathAlternative1 != null)
workingPathAlternative1 = URLEncoder.encode(workingPathAlternative1, niceURIEncoding);
String workingPathAlternative2 = workingPath;
if(workingPathAlternative2 != null)
workingPathAlternative2 = URLEncoder.encode(workingPathAlternative2, (niceURIEncoding.indexOf("8859") > -1 ? "utf-8" : "iso-8859-1")).replaceAll("\\+", "%20");
if(workingPath != null && url.indexOf(workingPath) == -1 && url.indexOf(workingPathAlternative1) == -1 && url.indexOf(workingPathAlternative2) == -1)
{
logger.info("This repo had a working path but the url did not include any sign of it - let's skip it");
continue;
}
}
else if(CmsPropertyHandler.getOperatingMode().equals("3"))
{
String livePathAlternative1 = livePath;
if(livePathAlternative1 != null)
livePathAlternative1 = URLEncoder.encode(livePathAlternative1, niceURIEncoding);
String livePathAlternative2 = livePath;
if(livePathAlternative2 != null)
livePathAlternative2 = URLEncoder.encode(livePathAlternative2, (niceURIEncoding.indexOf("8859") > -1 ? "utf-8" : "iso-8859-1")).replaceAll("\\+", "%20");
if(livePath != null && url.indexOf(livePath) == -1 && url.indexOf(livePathAlternative1) == -1 && url.indexOf(livePathAlternative2) == -1)
{
logger.info("This repo had a live path but the url did not include any sign of it - let's skip it");
continue;
}
}
String[] dnsNames = splitStrings(fullDnsNames.replaceAll("\\[.*?\\]", ""));
if(logger.isInfoEnabled())
logger.info("dnsNames:" + dnsNames);
for (int i=0;i<dnsNames.length;i++)
{
if(logger.isInfoEnabled())
logger.info("dnsNames["+i+"]:" + dnsNames[i]);
String dnsName = dnsNames[i];
if(dnsName.indexOf("undefined") > -1)
continue;
int index = dnsName.indexOf("working=,");
int indexMode = dnsName.indexOf("working=");
if(CmsPropertyHandler.getOperatingMode().equals("2"))
{
index = dnsName.indexOf("preview=,");
indexMode = dnsName.indexOf("preview=");
}
else if(CmsPropertyHandler.getOperatingMode().equals("3"))
{
index = dnsName.indexOf("live=,");
indexMode = dnsName.indexOf("live=");
}
boolean noHostName = (indexMode == -1);
if(logger.isInfoEnabled())
logger.info("" + index + ":" + indexMode + ":" + noHostName + ":" + dnsName + " for operationMode:" + CmsPropertyHandler.getOperatingMode());
if(/*!noHostName && */index == -1 && indexMode == -1 && dnsName.indexOf("=") > -1)
{
if(logger.isInfoEnabled())
logger.info("Skipping this name [" + dnsName + "] as it was not a dnsName targeted toward this mode.");
continue;
}
int protocolIndex = dnsName.indexOf("://");
if(protocolIndex > -1)
dnsName = dnsName.substring(protocolIndex + 3);
int portIndex = dnsName.indexOf(":");
if(portIndex > -1)
dnsName = dnsName.substring(0, portIndex);
logger.info("Matching only server name - removed protocol if there:" + dnsName);
if(logger.isInfoEnabled())
logger.info("dnsName:" + dnsName + ", serverName:" + serverName + ", repositoryName:" + repositoryName);
if(logger.isInfoEnabled())
{
logger.info("dnsName.indexOf(':'):" + dnsName.indexOf(":"));
logger.info("dnsName.indexOf(serverName) == 0:" + dnsName.indexOf(serverName));
logger.info("dnsName.indexOf(serverName + ':' + portNumber):" + dnsName.indexOf(serverName + ":" + portNumber));
logger.info("index:" + index);
logger.info("indexMode:" + indexMode);
}
if((dnsName.indexOf(":") == -1 && dnsName.indexOf(serverName) == 0) || dnsName.indexOf(serverName + ":" + portNumber) == 0 || index > -1 || indexMode == -1)
{
if(repositoryName != null && repositoryName.length() > 0)
{
logger.info("Has to check repositoryName also:" + repositoryVO.getName() + "=" + repositoryName + "=" + serverName);
if(repositoryVO.getName().equalsIgnoreCase(repositoryName))
{
if((dnsName.indexOf(":") == -1 && dnsName.indexOf(serverName) == 0) || dnsName.indexOf(serverName + ":" + portNumber) == 0)
{
//System.out.println("Adding " + repositoryVO.getName() + ":" + dnsName);
if(logger.isInfoEnabled())
logger.info("Adding " + repositoryVO.getName());
repositories.add(repositoryVO);
}
}
}
else
{
logger.info("dnsName:" + dnsName);
logger.info("serverName:" + serverName);
if(dnsName.startsWith(serverName))
{
logger.info("Adding 2:" + repositoryVO.getName() + "=" + repositoryName + "=" + serverName);
repositories.add(repositoryVO);
}
/*
logger.warn("Adding 2:" + repositoryVO.getName() + "=" + repositoryName);
repositories.add(repositoryVO);