Skip to content

Commit

Permalink
Updated for release 2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rmraya committed Aug 30, 2021
1 parent ef55302 commit 36d036a
Show file tree
Hide file tree
Showing 19 changed files with 501 additions and 629 deletions.
Binary file modified lib/openxliff.jar
Binary file not shown.
34 changes: 19 additions & 15 deletions src/com/maxprograms/fluenta/API.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import java.util.Date;
import java.util.Iterator;
import java.util.Vector;

import javax.xml.parsers.ParserConfigurationException;

import com.maxprograms.fluenta.controllers.LocalController;
import com.maxprograms.fluenta.models.Memory;
import com.maxprograms.fluenta.models.Project;
Expand All @@ -32,10 +36,12 @@
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.xml.sax.SAXException;

public class API {

protected static void addProject(String jsonFile) throws IOException {
protected static void addProject(String jsonFile)
throws IOException, ClassNotFoundException, SQLException, SAXException, ParserConfigurationException {
File projectFile = new File(jsonFile);
String string = ""; //$NON-NLS-1$
try (FileInputStream input = new FileInputStream(projectFile)) {
Expand Down Expand Up @@ -76,7 +82,8 @@ protected static void addProject(String jsonFile) throws IOException {
}

public static void addProject(long id, String title, String description, String map, String srcLang,
String[] tgtLang, long[] memIds) throws IOException {
String[] tgtLang, long[] memIds)
throws IOException, ClassNotFoundException, SQLException, SAXException, ParserConfigurationException {
Language srcLanguage = LanguageUtils.getLanguage(srcLang);

Vector<Language> tgtLanguages = new Vector<>();
Expand Down Expand Up @@ -222,7 +229,8 @@ public static void addMemory(long id, String title, String description, String s
controller.close();
}

public static void importMemory(long id, String tmxFile, boolean verbose) throws IOException {
public static void importMemory(long id, String tmxFile, boolean verbose)
throws IOException, ClassNotFoundException, SQLException, SAXException, ParserConfigurationException {
LocalController controller = new LocalController();
Memory memory = controller.getMemory(id);
if (memory == null) {
Expand Down Expand Up @@ -250,7 +258,8 @@ public static void exportMemory(long id, String tmxFile) throws Exception {
}

public static void generateXLIFF(long id, String xliffFolder, String[] tgtLang, boolean useICE, boolean useTM,
boolean generateCount, boolean verbose, String ditaval, boolean useXliff20) throws IOException {
boolean generateCount, boolean verbose, String ditaval, boolean useXliff20) throws IOException,
ClassNotFoundException, SAXException, ParserConfigurationException, URISyntaxException, SQLException {
LocalController controller = new LocalController();
Project project = controller.getProject(id);
if (project == null) {
Expand All @@ -272,13 +281,10 @@ public static void generateXLIFF(long id, String xliffFolder, String[] tgtLang,
controller.generateXliff(project, xliffFolder, langs, useICE, useTM, generateCount, ditaval, useXliff20,
logger);
controller.close();
if (logger.getSuccess()) {
return;
}
throw new IOException(logger.getError());
}

protected static void generateXLIFF(String jsonFile, boolean verbose) throws IOException {
protected static void generateXLIFF(String jsonFile, boolean verbose) throws IOException, SAXException,
ParserConfigurationException, URISyntaxException, ClassNotFoundException, SQLException {
File projectFile = new File(jsonFile);
String string = ""; //$NON-NLS-1$
try (FileInputStream input = new FileInputStream(projectFile)) {
Expand Down Expand Up @@ -319,7 +325,8 @@ protected static void generateXLIFF(String jsonFile, boolean verbose) throws IOE

public static void importXLIFF(long id, String xliffFile, String outputFolder, boolean updateTM,
boolean acceptUnapproved, boolean ignoreTagErrors, boolean cleanAttributes, boolean verbose)
throws IOException {
throws IOException, NumberFormatException, ClassNotFoundException, SAXException,
ParserConfigurationException, SQLException, URISyntaxException {
LocalController controller = new LocalController();
Project project = controller.getProject(id);
if (project == null) {
Expand All @@ -333,13 +340,10 @@ public static void importXLIFF(long id, String xliffFile, String outputFolder, b
SimpleLogger logger = new SimpleLogger(verbose);
controller.importXliff(project, xliffFile, outputFolder, updateTM, acceptUnapproved, ignoreTagErrors,
cleanAttributes, logger);
if (logger.getSuccess()) {
return;
}
throw new IOException(logger.getError());
}

protected static void importXLIFF(String jsonFile, boolean verbose) throws IOException {
protected static void importXLIFF(String jsonFile, boolean verbose) throws IOException, NumberFormatException,
ClassNotFoundException, SAXException, ParserConfigurationException, SQLException, URISyntaxException {
File projectFile = new File(jsonFile);
String string = ""; //$NON-NLS-1$
try (FileInputStream input = new FileInputStream(projectFile)) {
Expand Down
19 changes: 14 additions & 5 deletions src/com/maxprograms/fluenta/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@
import java.io.IOException;
import java.io.RandomAccessFile;
import java.io.UnsupportedEncodingException;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.net.URISyntaxException;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.SQLException;
import java.util.Date;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;

import javax.xml.parsers.ParserConfigurationException;

import com.maxprograms.utils.Preferences;

import org.xml.sax.SAXException;

public class CLI {

private static File lock;
Expand Down Expand Up @@ -113,7 +119,8 @@ public static void main(String[] args) {
if (addProject) {
try {
API.addProject(addFile);
} catch (IOException e) {
} catch (IOException | ClassNotFoundException | SQLException | SAXException
| ParserConfigurationException e) {
LOGGER.log(Level.ERROR, "Error adding project", e); //$NON-NLS-1$
System.exit(3);
}
Expand All @@ -130,15 +137,17 @@ public static void main(String[] args) {
if (generateXLIFF) {
try {
API.generateXLIFF(genXliffFile, verbose);
} catch (IOException ioe) {
} catch (IOException | ClassNotFoundException | SAXException | ParserConfigurationException
| URISyntaxException | SQLException ioe) {
LOGGER.log(Level.ERROR, "Error generating XLIFF", ioe); //$NON-NLS-1$
System.exit(3);
}
}
if (importXLIFF) {
try {
API.importXLIFF(xliffFile, verbose);
} catch (IOException ioe) {
} catch (IOException | NumberFormatException | ClassNotFoundException | SAXException
| ParserConfigurationException | SQLException | URISyntaxException ioe) {
LOGGER.log(Level.ERROR, "Error importing XLIFF", ioe); //$NON-NLS-1$
System.exit(3);
}
Expand Down
4 changes: 2 additions & 2 deletions src/com/maxprograms/fluenta/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ private Constants() {
}

public static final String NAME = "Fluenta"; //$NON-NLS-1$
public static final String VERSION = "2.0.0"; //$NON-NLS-1$
public static final String BUILD = "20210703_1145"; //$NON-NLS-1$
public static final String VERSION = "2.1.0"; //$NON-NLS-1$
public static final String BUILD = "202100827_1131"; //$NON-NLS-1$

public static final String SUCCESS = "0"; //$NON-NLS-1$
}
Loading

0 comments on commit 36d036a

Please sign in to comment.