应该和这个文件有联系的,能帮忙解释一下么?
import ff.il.internal.datasource.*;
import ff.il.internal.doctype.DocumentOperationManager;
import ff.il.internal.doctype.DocumentType;
import ff.il.internal.utils.RMIInputStreamImpl;
import ff.pl.apps.ffapp.utils.mapper.MimeTypeMapper;
import ff.tools.extern.DatasourceFactoryClient;
import ff.util.IdCreator;
import
import
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
public class TestArchive extends DatasourceFactoryClient
{
private Datasource ds;
private DocumentOperationManager fdom;
public TestArchive(final Properties props)
{
super(props);
}
/**
* {@inheritDoc}
*/
public void run() throws Exception
{
final String file = "D:\\testdata\\Winter.jpg";
final FileInputStream in = new FileInputStream(file);
in.available();
final String filename = new File(file).getName();
final String mimetype = MimeTypeMapper.getMimeTypeByFileName(filename);
final String language = uc.getLanguage();
int count = ds.count(DatasourceUtils.EMPTY_SELECTION);
int documents = 1;
Record record = new Record ();
final Collection<Selection> what = new ArrayList<Selection>(1);
for (int i = count; i < (count + documents); i++)
{
record.clear();
what.clear();
record.put("LFDNR", i);
record.put("STRING_1", "String_1_" + i);
record.put("STRING_2", "String_2_" + i);
record.put("STRING_3", "String_3_" + i);
ds.insert(record);
what.add(new Selection("LFDNR", BigInteger.valueOf(i)));
final CRecord cr = (CRecord) ds.select(DatasourceUtils.EMPTY_ATTRIBUTES, what, DatasourceUtils.EMPTY_ORDER).iterator().next();
fdom.addDocument(new RMIInputStreamImpl(new FileInputStream(file)), mimetype,
filename, cr, null, null, language, null, null);
}
}
/**
* {@inheritDoc}
*/
protected void initObjects() throws Exception
{
super.initObjects();
ds = dsf.getDatasource(uc, new IdCreator(cid, project_name, version_id, "DATA"));
final DocumentType fdt = dtf.getDocumentType(new IdCreator(cid, project_name, version_id), "DOCTYPE");
fdom = fdt.getDocumentOperationManager(uc, dsf);
}
public static void main(final String[] args)
{
try
{
final Properties props = new Properties();
props.setProperty(PROP_LOGPATH, "../log2");
props.setProperty(PROP_LOGFILENAME_PREFIX_FROM_CLASS, String.valueOf(true));
props.setProperty(PROP_LOGLEVEL, String.valueOf(8));
props.setProperty(PROP_RMI_PORT, String.valueOf(16100));
props.setProperty(PROP_CID, String.valueOf(10));
props.setProperty(PROP_CLIENT, DatasourceConstants.DEFAULT_CLIENT);
props.setProperty(PROP_LOGIN_USER, "root");
props.setProperty(PROP_LOGIN_PWD, "rootroot");
props.setProperty(PROP_PROJECT_NAME, "MASTER");
final TestArchive impl = new TestArchive(props);
impl.init(args);
int count;
try
{
count = Integer.parseInt(args[0]);
}
catch (final Exception ignored)
{
count = 1;
}
for (int i = 0; i < count; ++i)
{
impl.run();
}
System.exit(0);
}
catch (final Throwable ex)
{
ex.printStackTrace(System.err);
System.exit(1);
}
}
}