Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ru.it.metasonic.workshop.actions;
- import java.io.BufferedReader;
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.io.InputStream;
- import java.io.InputStreamReader;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.Properties;
- import org.apache.commons.logging.Log;
- import org.apache.commons.logging.LogFactory;
- import ru.it.metasonic.workshop.bo1.BO1View;
- import de.metasonic.businessobjects.model.rules.AbstractServerAction;
- public class action1 extends AbstractServerAction {
- Log log = LogFactory.getLog(action1.class);
- public final static String PROPERTY_HOME = "jcom1.property_home";
- public final static String PROPERTY_FILE = "ru.it.metasonic.workshop.properties";
- public final static String PROPERTY_NAME = "string4Default";
- private File dir, currentFile;
- private BufferedReader reader;
- public void initBO() {
- log.debug(">>>startting BO");
- boolean readingCurrently = false;
- String text = "";
- dir = new File("/C:/Users/anthony/Documents/Metasonic Workshop/Development/Metasonic_Suite/plugins/com.jcom1.propertyfiles_5.2.1.201505132000/in_files/");
- File filesList[] = dir.listFiles();
- if (null != filesList || 0!= filesList.length) {
- currentFile = filesList[0];
- log.debug("-->currFile:" + currentFile.toString());
- try {
- reader = new BufferedReader(new InputStreamReader(
- new FileInputStream(currentFile)));
- readingCurrently = true;
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- log.error(e);
- //e.printStackTrace();
- }
- }
- if (readingCurrently) {
- try {
- String line;
- while (null != (line = reader.readLine())) {
- text += line + " ";
- }
- reader.close();
- currentFile.delete();
- log.debug("file has been deleted");
- } catch (IOException e) {
- // TODO Auto-generated catch block
- //e.printStackTrace();
- log.error(e);
- }
- }
- BO1View bo1View = (BO1View)getBean();
- bo1View.setString2(text);
- //SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
- //bo1View.setString2(sdf.format(new Date()));
- //log.debug("string2: " + bo1View.getString2());
- /*String propertyHome = System.getProperty(PROPERTY_HOME);
- log.debug("propertyHome: " + propertyHome);
- Properties properties = new Properties();
- File file = new File(propertyHome + "/" + PROPERTY_FILE);
- InputStream inputStream = null;
- try {
- try {
- inputStream = new FileInputStream(file);
- properties.load(inputStream);
- String defaultValue = properties.getProperty(PROPERTY_NAME);
- log.debug("defaultValue: " + defaultValue);
- bo1View.setString4(defaultValue);
- } finally {
- if (null != inputStream) {
- inputStream.close();
- }
- }
- } catch(Exception e) {
- log.error(e);
- }*/
- }
- public void updateBO() {
- BO1View bo1View = (BO1View)getBean();
- String string1 = bo1View.getString1();
- String string3 = string1.toUpperCase();
- bo1View.setString3(string3);
- log.debug("string3: " + bo1View.getString3());
- }
- }
Add Comment
Please, Sign In to add comment