Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #1516

Merged
merged 8 commits into from
Jul 9, 2019
Merged

Fix bug #1516

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
public class UtilAndComs {

public static final String VERSION = "Nacos-Java-Client:v1.0.1";
public static final String VERSION = "Nacos-Java-Client:v1.1.1";

public static String WEB_CONTEXT = "/nacos";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.alibaba.nacos.config.server.service.trace.ConfigTraceService;
import com.alibaba.nacos.config.server.utils.*;
import com.alibaba.nacos.config.server.utils.event.EventDispatcher;
import com.google.common.base.Joiner;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.slf4j.Logger;
Expand Down Expand Up @@ -402,14 +401,14 @@ public RestResult<ConfigInfo4Beta> queryBeta(HttpServletRequest request, HttpSer
@ResponseBody
public ResponseEntity<byte[]> exportConfig(HttpServletRequest request,
HttpServletResponse response,
@RequestParam("group") String group,
@RequestParam(value = "dataId", required = false) String dataId,
@RequestParam(value = "group", required = false) String group,
@RequestParam(value = "appName", required = false) String appName,
@RequestParam(value = "tenant", required = false,
defaultValue = StringUtils.EMPTY) String tenant,
@RequestParam(value = "ids", required = false)List<Long> ids) {
ids.removeAll(Collections.singleton(null));
String idsStr = Joiner.on(",").join(ids);
List<ConfigInfo> dataList = persistService.findAllConfigInfo4Export(group, tenant, appName, idsStr);
List<ConfigInfo> dataList = persistService.findAllConfigInfo4Export(dataId, group, tenant, appName, ids);
List<ZipUtils.ZipItem> zipItemList = new ArrayList<>();
StringBuilder metaData = null;
for(ConfigInfo ci : dataList){
Expand Down Expand Up @@ -544,8 +543,7 @@ public RestResult<Map<String, Object>> cloneConfig(HttpServletRequest request,
}

ids.removeAll(Collections.singleton(null));
String idsStr = Joiner.on(",").join(ids);
List<ConfigInfo> queryedDataList = persistService.findAllConfigInfo4Export(null, null, null, idsStr);
List<ConfigInfo> queryedDataList = persistService.findAllConfigInfo4Export(null,null, null, null, ids);

if(queryedDataList == null || queryedDataList.isEmpty()){
failedData.put("succCount", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.alibaba.nacos.config.server.service;

import com.alibaba.nacos.config.server.utils.PropertyUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
Expand All @@ -30,6 +31,9 @@
@Component
public class DynamicDataSource implements ApplicationContextAware {

@Autowired
private PropertyUtil propertyUtil;

private ApplicationContext applicationContext;

@Override
Expand All @@ -44,7 +48,7 @@ public ApplicationContext getApplicationContext() {
public DataSourceService getDataSource() {
DataSourceService dataSourceService = null;

if (STANDALONE_MODE && !PropertyUtil.isStandaloneUseMysql()) {
if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) {
dataSourceService = (DataSourceService)applicationContext.getBean("localDataSourceService");
} else {
dataSourceService = (DataSourceService)applicationContext.getBean("basicDataSourceService");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.commons.dbcp.BasicDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -61,6 +62,9 @@ public class LocalDataSourceServiceImpl implements DataSourceService {
private JdbcTemplate jt;
private TransactionTemplate tjt;

@Autowired
private PropertyUtil propertyUtil;

@PostConstruct
public void init() {
BasicDataSource ds = new BasicDataSource();
Expand All @@ -86,7 +90,7 @@ public void init() {
tm.setDataSource(ds);
tjt.setTimeout(5000);

if (STANDALONE_MODE && !PropertyUtil.isStandaloneUseMysql()) {
if (STANDALONE_MODE && !propertyUtil.isStandaloneUseMysql()) {
reload();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3298,16 +3298,28 @@ public Boolean completeMd5() {
* @param group
* @return Collection of ConfigInfo objects
*/
public List<ConfigInfo> findAllConfigInfo4Export(final String group, final String tenant,
final String appName, final String ids) {
public List<ConfigInfo> findAllConfigInfo4Export(final String dataId, final String group, final String tenant,
final String appName, final List<Long> ids) {
String tenantTmp = StringUtils.isBlank(tenant) ? StringUtils.EMPTY : tenant;
StringBuilder where = new StringBuilder(" where ");
List<String> paramList = new ArrayList<>();
if(StringUtils.isNotBlank(ids)){
where.append(" id in (").append(ids).append(") ");
List<Object> paramList = new ArrayList<>();
if(!CollectionUtils.isEmpty(ids)){
where.append(" id in (");
for (int i = 0; i < ids.size(); i++) {
if (i != 0) {
where.append(", ");
}
where.append("?");
paramList.add(ids.get(i));
}
where.append(") ");
} else {
where.append(" tenant_id=? ");
paramList.add(tenantTmp);
if (!StringUtils.isBlank(dataId)) {
where.append(" and data_id like ? ");
paramList.add(generateLikeArgument(dataId));
}
if (StringUtils.isNotBlank(group)) {
where.append(" and group_id=? ");
paramList.add(group);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,10 @@ public static UnZipResult unzip(byte[] source) {
ZipItem metaDataItem = null;
try (ZipInputStream zipIn = new ZipInputStream(new ByteArrayInputStream(source))) {
ZipEntry entry;
while ((entry = zipIn.getNextEntry()) != null && !entry.isDirectory()) {
while ((entry = zipIn.getNextEntry()) != null) {
if(entry.isDirectory()){
continue;
}
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
byte[] buffer = new byte[1024];
int offset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -673,9 +673,10 @@ class ConfigurationManagement extends React.Component {
}

exportData() {
let url = `v1/cs/configs?export=true&group=${this.group}&tenant=${getParams(
'namespace'
)}&appName=${this.appName}&ids=`;
let url =
`v1/cs/configs?export=true&group=${this.group}&tenant=${getParams('namespace')}&appName=${
this.appName
}&ids=&dataId=` + this.dataId;
window.location.href = url;
}

Expand Down
2 changes: 1 addition & 1 deletion console/src/main/resources/static/css/main.css

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion distribution/bin/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ else
fi

JAVA_OPT="${JAVA_OPT} -Dnacos.home=${BASE_DIR}"
JAVA_OPT="${JAVA_OPT} -jar ${BASE_DIR}/target/${SERVER}.jar"
JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}"
JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/nacos-logback.xml"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ public JSONObject doSrvIPXT(String namespaceId, String serviceName, String agent
if (Loggers.DEBUG_LOG.isDebugEnabled()) {
Loggers.DEBUG_LOG.debug("no instance to serve for service: " + serviceName);
}
result.put("name", serviceName);
result.put("hosts", new JSONArray());
return result;
}
Expand Down