starting #22385
This commit is contained in:
parent
8d4b6d6c3f
commit
3039279092
|
@ -77,7 +77,7 @@ public class UriResolverManager {
|
||||||
return usingReader;
|
return usingReader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Logger logger = LoggerFactory.getLogger(UriResolverManager.class);
|
public static final Logger LOG = LoggerFactory.getLogger(UriResolverManager.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new uri resolver manager. Precondition: set the scope into
|
* Instantiates a new uri resolver manager. Precondition: set the scope into
|
||||||
|
@ -94,7 +94,7 @@ public class UriResolverManager {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String scope = ScopeProvider.instance.get();
|
String scope = ScopeProvider.instance.get();
|
||||||
logger.info("UriResolverManager is using scope: " + scope + ", read from ScopeProvider");
|
LOG.info("UriResolverManager is using scope: " + scope + ", read from ScopeProvider");
|
||||||
|
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
throw new UriResolverMapException("Scope is null, set scope into ScopeProvider!");
|
throw new UriResolverMapException("Scope is null, set scope into ScopeProvider!");
|
||||||
|
@ -103,10 +103,10 @@ public class UriResolverManager {
|
||||||
this.applicationTypes = uriResolverMapReader.getApplicationTypes();
|
this.applicationTypes = uriResolverMapReader.getApplicationTypes();
|
||||||
// this.setTimerUriResolverReader(RESET_DELAY, RESET_TIME);
|
// this.setTimerUriResolverReader(RESET_DELAY, RESET_TIME);
|
||||||
} catch (UriResolverMapException e) {
|
} catch (UriResolverMapException e) {
|
||||||
logger.error("UriResolverMapException: ", e);
|
LOG.error("UriResolverMapException: ", e);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("UriResolverManager: ", e);
|
LOG.error("UriResolverManager: ", e);
|
||||||
throw new UriResolverMapException("Map Application Type - Resources not found in IS");
|
throw new UriResolverMapException("Map Application Type - Resources not found in IS");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,16 +184,16 @@ public class UriResolverManager {
|
||||||
// lockReader();
|
// lockReader();
|
||||||
|
|
||||||
if (reader == null) {
|
if (reader == null) {
|
||||||
logger.info("Runtime Resource Reader is null, istancing...");
|
LOG.info("Runtime Resource Reader is null, istancing...");
|
||||||
reader = new RuntimeResourceReader(resolver.getResourceName());
|
reader = new RuntimeResourceReader(resolver.getResourceName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (resolver.getEntryName() == null || resolver.getEntryName().isEmpty()) {
|
if (resolver.getEntryName() == null || resolver.getEntryName().isEmpty()) {
|
||||||
logger.warn("The entryname to " + resolver.getResourceName()
|
LOG.warn("The entryname to " + resolver.getResourceName()
|
||||||
+ " is null or empty, reading first Access Point!!");
|
+ " is null or empty, reading first Access Point!!");
|
||||||
serviceAccessPoint = reader.getServiceAccessPoints().get(0);
|
serviceAccessPoint = reader.getServiceAccessPoints().get(0);
|
||||||
} else {
|
} else {
|
||||||
logger.warn("Reading Access Point for Entry Name: " + resolver.getEntryName());
|
LOG.warn("Reading Access Point for Entry Name: " + resolver.getEntryName());
|
||||||
serviceAccessPoint = reader.getServiceAccessPointForEntryName(resolver.getEntryName());
|
serviceAccessPoint = reader.getServiceAccessPointForEntryName(resolver.getEntryName());
|
||||||
if (serviceAccessPoint == null)
|
if (serviceAccessPoint == null)
|
||||||
throw new UriResolverMapException("Entry Name " + resolver.getEntryName()
|
throw new UriResolverMapException("Entry Name " + resolver.getEntryName()
|
||||||
|
@ -217,7 +217,7 @@ public class UriResolverManager {
|
||||||
try {
|
try {
|
||||||
return resolver.getLink(baseURI, parameters);
|
return resolver.getLink(baseURI, parameters);
|
||||||
} catch (NotImplementedException e) {
|
} catch (NotImplementedException e) {
|
||||||
logger.info("Get Link not implemented, going to default implementation by GET Request");
|
LOG.info("Get Link not implemented, going to default implementation by GET Request");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Encoding only the query string
|
// Encoding only the query string
|
||||||
|
@ -229,46 +229,46 @@ public class UriResolverManager {
|
||||||
// parameters encoded
|
// parameters encoded
|
||||||
queryString = UrlEncoderUtil.encodeQuery(parameters);
|
queryString = UrlEncoderUtil.encodeQuery(parameters);
|
||||||
String toReturn = String.format("%s?%s", baseURI, queryString);
|
String toReturn = String.format("%s?%s", baseURI, queryString);
|
||||||
logger.info("returning link with encoded parameters in the query string: " + toReturn);
|
LOG.info("returning link with encoded parameters in the query string: " + toReturn);
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
queryString = UrlEncoderUtil.toQueryString(parameters);
|
queryString = UrlEncoderUtil.toQueryString(parameters);
|
||||||
linkDecoded = String.format("%s?%s", baseURI, queryString);
|
linkDecoded = String.format("%s?%s", baseURI, queryString);
|
||||||
link = linkDecoded;
|
link = linkDecoded;
|
||||||
logger.info("Created HTTP URI request (link): " + link);
|
LOG.info("Created HTTP URI request (link): " + link);
|
||||||
if (shortLink) {
|
if (shortLink) {
|
||||||
try {
|
try {
|
||||||
String queryStringEncoded = UrlEncoderUtil.encodeString(queryString);
|
String queryStringEncoded = UrlEncoderUtil.encodeString(queryString);
|
||||||
link = String.format("%s?%s", baseURI, queryStringEncoded);
|
link = String.format("%s?%s", baseURI, queryStringEncoded);
|
||||||
logger.info("Encoded link is: " + link);
|
LOG.info("Encoded link is: " + link);
|
||||||
logger.info("Shortner start..");
|
LOG.info("Shortner start..");
|
||||||
UrlShortener shortener = new UrlShortener();
|
UrlShortener shortener = new UrlShortener();
|
||||||
String shortedLink = shortener.shorten(link);
|
String shortedLink = shortener.shorten(link);
|
||||||
logger.info("Shorted link is: " + shortedLink);
|
LOG.info("Shorted link is: " + shortedLink);
|
||||||
if (shortedLink != null && shortedLink.equals(link)) {
|
if (shortedLink != null && shortedLink.equals(link)) {
|
||||||
// here the short link and the input link are identical
|
// here the short link and the input link are identical
|
||||||
// so the shortening did not work
|
// so the shortening did not work
|
||||||
// I'm returning the decoded link because it is directly consumable via browser
|
// I'm returning the decoded link because it is directly consumable via browser
|
||||||
logger.debug("Shorted link is equal to input link, returning decoded link: " + linkDecoded);
|
LOG.debug("Shorted link is equal to input link, returning decoded link: " + linkDecoded);
|
||||||
link = linkDecoded;
|
link = linkDecoded;
|
||||||
} else {
|
} else {
|
||||||
// here the link is really shorted
|
// here the link is really shorted
|
||||||
logger.debug("The link is really shorted, returning it");
|
LOG.debug("The link is really shorted, returning it");
|
||||||
link = shortedLink;
|
link = shortedLink;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.warn("An error occurred during link shortening: ", e);
|
LOG.warn("An error occurred during link shortening: ", e);
|
||||||
// here I'm returning the decoded link in case of error on shortening it
|
// here I'm returning the decoded link in case of error on shortening it
|
||||||
link = linkDecoded;
|
link = linkDecoded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
logger.error("Uri Resolver IllegalArgumentException: ", e);
|
LOG.error("Uri Resolver IllegalArgumentException: ", e);
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Uri Resolver Exception: ", e);
|
LOG.error("Uri Resolver Exception: ", e);
|
||||||
throw new UriResolverMapException("Uri Resolver error: " + e.getMessage());
|
throw new UriResolverMapException("Uri Resolver error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ public class UriResolverManager {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
String scope = ScopeProvider.instance.get();
|
String scope = ScopeProvider.instance.get();
|
||||||
logger.info("SiscoveryServiceParameters is using scope: " + scope + ", read from ScopeProvider");
|
LOG.info("SiscoveryServiceParameters is using scope: " + scope + ", read from ScopeProvider");
|
||||||
|
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
throw new UriResolverMapException("Scope is null, set scope into ScopeProvider!");
|
throw new UriResolverMapException("Scope is null, set scope into ScopeProvider!");
|
||||||
|
@ -309,11 +309,11 @@ public class UriResolverManager {
|
||||||
|
|
||||||
ServiceAccessPoint serviceAccessPoint = null;
|
ServiceAccessPoint serviceAccessPoint = null;
|
||||||
if (resolver.getEntryName() == null || resolver.getEntryName().isEmpty()) {
|
if (resolver.getEntryName() == null || resolver.getEntryName().isEmpty()) {
|
||||||
logger.warn("The entryname to " + resolver.getResourceName()
|
LOG.warn("The entryname to " + resolver.getResourceName()
|
||||||
+ " is null or empty, reading first Access Point!!");
|
+ " is null or empty, reading first Access Point!!");
|
||||||
serviceAccessPoint = reader.getServiceAccessPoints().get(0);
|
serviceAccessPoint = reader.getServiceAccessPoints().get(0);
|
||||||
} else {
|
} else {
|
||||||
logger.info("Reading Access Point for entryname: " + resolver.getEntryName());
|
LOG.info("Reading Access Point for entryname: " + resolver.getEntryName());
|
||||||
serviceAccessPoint = reader.getServiceAccessPointForEntryName(resolver.getEntryName());
|
serviceAccessPoint = reader.getServiceAccessPointForEntryName(resolver.getEntryName());
|
||||||
if (serviceAccessPoint == null)
|
if (serviceAccessPoint == null)
|
||||||
throw new UriResolverMapException("Entry Name " + resolver.getEntryName()
|
throw new UriResolverMapException("Entry Name " + resolver.getEntryName()
|
||||||
|
@ -322,7 +322,7 @@ public class UriResolverManager {
|
||||||
|
|
||||||
return serviceAccessPoint.getServiceParameters();
|
return serviceAccessPoint.getServiceParameters();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Uri Resolver error: ", e);
|
LOG.error("Uri Resolver error: ", e);
|
||||||
throw new UriResolverMapException("Uri Resolver error: " + e.getMessage());
|
throw new UriResolverMapException("Uri Resolver error: " + e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -361,13 +361,13 @@ public class UriResolverManager {
|
||||||
timer.schedule(new TimerTask() {
|
timer.schedule(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
logger.info("Timer Reset Runtime Resource running..");
|
LOG.info("Timer Reset Runtime Resource running..");
|
||||||
int counters = countReaders();
|
int counters = countReaders();
|
||||||
if (counters == 0) {
|
if (counters == 0) {
|
||||||
logger.info("Reader not locked, resetting");
|
LOG.info("Reader not locked, resetting");
|
||||||
reader = null;
|
reader = null;
|
||||||
} else
|
} else
|
||||||
logger.info("Reader locked, counters is/are:" + counters + ", skipping");
|
LOG.info("Reader locked, counters is/are:" + counters + ", skipping");
|
||||||
|
|
||||||
}
|
}
|
||||||
}, delay, period);
|
}, delay, period);
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class UriResolverMapReader {
|
||||||
public static final String URIRESOLVERMAP_SECONDARY_TYPE = "UriResolverMap";
|
public static final String URIRESOLVERMAP_SECONDARY_TYPE = "UriResolverMap";
|
||||||
public static final String URI_RESOLVER_MAP_RESOURCE_NAME = "Uri-Resolver-Map";
|
public static final String URI_RESOLVER_MAP_RESOURCE_NAME = "Uri-Resolver-Map";
|
||||||
|
|
||||||
// private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
// private Logger LOG = LoggerFactory.getLogger(UriResolverMapReader.class);
|
||||||
// TODO TEMP SOLUTION IN ORDER TO PRINT USING ALSO LOG4J INTO GEOEXPLORER
|
// TODO TEMP SOLUTION IN ORDER TO PRINT USING ALSO LOG4J INTO GEOEXPLORER
|
||||||
// PORTLET
|
// PORTLET
|
||||||
private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
private Logger logger = LoggerFactory.getLogger(UriResolverMapReader.class);
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class HttpRequestUtil {
|
||||||
}else
|
}else
|
||||||
logger.warn("status code is "+code+" - on url connection: "+urlConn);
|
logger.warn("status code is "+code+" - on url connection: "+urlConn);
|
||||||
|
|
||||||
// logger.trace("result: "+result);
|
// LOG.trace("result: "+result);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
logger.error("error - not a http request!");
|
logger.error("error - not a http request!");
|
||||||
|
|
Loading…
Reference in New Issue