clear code with findbugs plugin and change the version to 1.1

This commit is contained in:
jy.hu
2014-12-18 11:32:14 +08:00
parent 54963b283c
commit 5b8666d2f0
49 changed files with 419 additions and 231 deletions
+8 -2
View File
@@ -1,10 +1,11 @@
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.foxinmy</groupId>
<artifactId>weixin4j-qy</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>weixin4j-qy-api</artifactId>
<name>weixin4j-qy-api</name>
@@ -22,6 +23,11 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.foxinmy</groupId>
<artifactId>weixin4j-base</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.entity.mime.content.ByteArrayBody;
@@ -121,7 +122,7 @@ public class MediaApi extends QyApi {
* @see {@link com.foxinmy.weixin4j.qy.api.MediaApi#downloadMedia(String)}
*/
public File downloadMedia(String mediaId, String extension)
throws WeixinException, IOException {
throws WeixinException {
String media_path = ConfigUtil.getValue("media_path");
File file = new File(media_path + File.separator + mediaId + "."
+ extension);
@@ -129,10 +130,27 @@ public class MediaApi extends QyApi {
return file;
}
byte[] datas = downloadMedia(mediaId);
file.createNewFile();
FileOutputStream out = new FileOutputStream(file);
out.write(datas);
out.close();
OutputStream os = null;
try {
boolean flag = file.createNewFile();
if (flag) {
os = new FileOutputStream(file);
os.write(datas);
} else {
throw new WeixinException("-1", String.format(
"create file fail:%s", file.getAbsolutePath()));
}
} catch (IOException e) {
throw new WeixinException("-1", e.getMessage());
} finally {
try {
if (os != null) {
os.close();
}
} catch (IOException ignore) {
;
}
}
return file;
}
@@ -15,8 +15,14 @@ import com.foxinmy.weixin4j.api.BaseApi;
* @see <a href="http://qydev.weixin.qq.com/wiki/index.php">api文档</a>
*/
public class QyApi extends BaseApi {
private final static ResourceBundle weixinBundle;
static {
weixinBundle = ResourceBundle
.getBundle("com/foxinmy/weixin4j/qy/api/weixin");
}
@Override
protected ResourceBundle getWeixinBundle() {
return weixinBundle;
}
}