Commit b459dde7 authored by o2null's avatar o2null
Browse files

Merge branch 'hotfix/应用市场通过官网cdn下载' into 'master'

hotfix/应用市场通过官网cdn下载

See merge request o2oa/o2oa!6449
No related merge requests found
Showing with 33 additions and 5 deletions
+33 -5
......@@ -34,6 +34,7 @@ public class Collect extends ConfigObject {
public static String ADDRESS_COLLECT_VALIDATE = "/o2_collect_assemble/jaxrs/unit/validate";
public static String ADDRESS_COLLECT_VALIDATE_CODE = "/o2_collect_assemble/jaxrs/unit/validate/codeanswer";
public static String ADDRESS_COLLECT_APPLICATION_LIST = "/o2_collect_assemble/jaxrs/application/list";
public static String ADDRESS_COLLECT_MARKET = "/market";
public static String ADDRESS_COLLECT_APPLICATION_DOWN = "/o2_collect_assemble/jaxrs/application/download";
public static String COLLECT_TOKEN = "c-token";
public static String ADDRESS_APPPACK_AUTH = "/auth/collect";
......
......@@ -77,6 +77,14 @@ public class ConnectionAction {
connection.setReadTimeout(readTimeout);
try {
connection.connect();
int status = connection.getResponseCode();
if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM) {
String redirect = connection.getHeaderField("Location");
if(StringUtils.isNotBlank(redirect)) {
connection.disconnect();
return getDelete(connectTimeout, readTimeout, redirect, method, heads);
}
}
} catch (Exception e) {
response.setType(Type.connectFatal);
response.setMessage(String.format("%s connect connection error, address: %s, because: %s.", method, address,
......@@ -188,6 +196,14 @@ public class ConnectionAction {
String.format("%s ouput error, address: %s, because: %s.", method, address, e.getMessage()));
return response;
}
int status = connection.getResponseCode();
if (status == HttpURLConnection.HTTP_MOVED_TEMP || status == HttpURLConnection.HTTP_MOVED_PERM) {
String redirect = connection.getHeaderField("Location");
if(StringUtils.isNotBlank(redirect)) {
connection.disconnect();
return postPut(connectTimeout, readTimeout, redirect, method, heads, body);
}
}
return read(response, connection);
}
......@@ -506,4 +522,4 @@ public class ConnectionAction {
map.entrySet().forEach((o -> connection.addRequestProperty(o.getKey(), o.getValue())));
}
}
\ No newline at end of file
}
......@@ -44,11 +44,11 @@ public class CollectMarket extends BaseAction {
Business business = new Business(emc);
String token = business.loginCollect();
if (StringUtils.isNotEmpty(token)) {
logger.debug("start sync market data=====");
logger.info("start sync market data=====");
List<Wi> wiList = null;
try {
ActionResponse response = ConnectionAction.get(
Config.collect().url(Collect.ADDRESS_COLLECT_APPLICATION_LIST),
Config.collect().url(Collect.ADDRESS_COLLECT_MARKET),
ListTools.toList(new NameValuePair(Collect.COLLECT_TOKEN, token)));
wiList = response.getDataAsList(Wi.class);
} catch (Exception e) {
......@@ -112,7 +112,7 @@ public class CollectMarket extends BaseAction {
}
emc.commit();
}
logger.debug("end sync market data=====");
logger.info("end sync market data=====");
}
}
}
......@@ -140,4 +140,15 @@ public class CollectMarket extends BaseAction {
}
}
}
\ No newline at end of file
public static void main(String[] args) throws Exception{
System.out.println("==========1");
ActionResponse response1 = ConnectionAction.get(
"http://collect.o2oa.net:20080/market",
ListTools.toList(new NameValuePair(Collect.COLLECT_TOKEN, "DltLNMgB3BaKEeBBjgHVADkfpuTt3sqriL15iT2Cjgk")));
List<Wi> wiList = response1.getDataAsList(Wi.class);
System.out.println("wait sync market app size:"+ wiList.size());
System.out.println("==========2");
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment