import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
-import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.ResourceBundle;
import nu.xom.ParsingException;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.io.filefilter.WildcardFileFilter;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import fr.gouv.finances.dgfip.xemelios.common.config.RecherchePaireModel;
import fr.gouv.finances.dgfip.xemelios.common.config.SpecialKeyModel;
import fr.gouv.finances.dgfip.xemelios.data.AbstractDataImpl;
-import fr.gouv.finances.dgfip.xemelios.data.ArchiveLocator;
import fr.gouv.finances.dgfip.xemelios.data.DataAccessException;
import fr.gouv.finances.dgfip.xemelios.data.DataConfigurationException;
import fr.gouv.finances.dgfip.xemelios.data.DataLayerManager;
public class OracleDataLayer extends AbstractDataImpl implements MessageEntries {
public static final transient String LAYER_NAME = "oracle";
static {
- DataLayerManager.regiterDataImpl(LAYER_NAME, OracleDataLayer.class);
+ DataLayerManager.regiterDataImpl(OracleDataLayer.LAYER_NAME, OracleDataLayer.class);
}
public static final transient String PROP_CONFIG_FILE_NAME = "xemelios.oracle.config.filename";
public static final transient String ORDER_BY_REPLACEMENT = "##order.by##";
// contains()
// ca doit impérativement être synchronisé, donc Hashtable requise
private Hashtable<Thread, StringBuilder> warnings;
- private ArchiveLocator archiveLocator = new SplArchiveLocator();// beurk...
private static Hashtable<String, TCriteria.FunctionEvaluator> evaluators = null;
static {
- evaluators = new Hashtable<String, TCriteria.FunctionEvaluator>();
- evaluators.put("string-compare", new StrCompareEvaluator());
- evaluators.put("date-compare", new DateCompareEvaluator());
+ OracleDataLayer.evaluators = new Hashtable<String, TCriteria.FunctionEvaluator>();
+ OracleDataLayer.evaluators.put("string-compare", new StrCompareEvaluator());
+ OracleDataLayer.evaluators.put("date-compare", new DateCompareEvaluator());
}
private static final SimpleDateFormat oracleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- public OracleDataLayer(PropertiesExpansion applicationConfiguration) throws DataConfigurationException {
+ public OracleDataLayer(final PropertiesExpansion applicationConfiguration) throws DataConfigurationException {
super();
- logger.info("instancing");
+ OracleDataLayer.logger.info("instancing");
this.applicationProperties = applicationConfiguration;
- initConnections();
- domFactory = FactoryProvider.getDocumentBuilderFactory();
- xPathFactory = FactoryProvider.getXPathFactory();
- saxFactory = FactoryProvider.getSaxParserFactory();
- createdTables = new TreeSet<String>();
- warnings = new Hashtable<Thread, StringBuilder>();
+ this.domFactory = FactoryProvider.getDocumentBuilderFactory();
+ this.xPathFactory = FactoryProvider.getXPathFactory();
+ this.saxFactory = FactoryProvider.getSaxParserFactory();
+ this.createdTables = new TreeSet<String>();
+ this.warnings = new Hashtable<Thread, StringBuilder>();
+ this.archiveLocator = new SplArchiveLocator();// TODO : à paramétrer dégueux
}
/**
* Initialise le pool de connection, crée les tables nécessaires
- *
- * @throws DataConfigurationException
*/
- private void initConnections() throws DataConfigurationException {
- String configFileName = getApplicationProperty(PROP_CONFIG_FILE_NAME);
- Properties props = new PropertiesExpansion();
+ @Override
+ protected void initConnections() throws Exception {
+ final String configFileName = this.getApplicationProperty(OracleDataLayer.PROP_CONFIG_FILE_NAME);
+ final Properties props = new PropertiesExpansion();
Connection pCon = null;
try {
try {
props.load(new FileInputStream(configFileName));
- } catch (NullPointerException npEx) {
+ } catch (final NullPointerException npEx) {
// si ça a déjà été initialisé, cela peut être nul
}
PoolManager.getInstance().init(props);
pCon = PoolManager.getInstance().getConnection();
- Statement st = pCon.createStatement();
+ final Statement st = pCon.createStatement();
// table de gestion des versions de tables
try {
st.executeQuery("SELECT 1 FROM TABLES_VERSIONS").close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
// la table n'existe pas
st.executeUpdate("CREATE TABLE TABLES_VERSIONS (TABLE_NAME VARCHAR2(64) NOT NULL, VERSION INT NOT NULL)");
}
// table des configurations des exports
try {
st.executeQuery("SELECT 1 FROM CONFIGS_EXPORT").close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
// la table n'existe pas
st.executeUpdate("CREATE TABLE CONFIGS_EXPORT (ID INT NOT NULL, DOC_ID VARCHAR2(100) NOT NULL, ETAT_ID VARCHAR2(100) NOT NULL, OWNER VARCHAR2(25) NOT NULL, DATE_CREA TIMESTAMP NOT NULL, CODE VARCHAR2(250) NOT NULL, LIBELLE VARCHAR2(200) NOT NULL, CONFIG BLOB NOT NULL, constraint pk_cfg_exp PRIMARY KEY (ID, DOC_ID, ETAT_ID))");
st.executeUpdate("CREATE SEQUENCE SQ_CFG_EXPORTS START WITH 1 INCREMENT BY 1 NOMAXVALUE");
// dernières valeurs saisies
try {
st.executeQuery("SELECT 1 FROM LAST_INPUT_VALUES").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE LAST_INPUT_VALUES (USER_ID VARCHAR2(50) NOT NULL, INPUT_ID VARCHAR2(250) NOT NULL, VALUE VARCHAR2(250) )");
st.executeUpdate("CREATE UNIQUE INDEX IX_LIV_UN ON LAST_INPUT_VALUES (USER_ID, INPUT_ID)");
}
try {
st.executeQuery("SELECT 1 FROM SAVED_REQUESTS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE SAVED_REQUESTS (ID VARCHAR2(250) NOT NULL, REQUEST BLOB, KEY_EM VARCHAR2(250) NOT NULL, USER_ID VARCHAR2(50) NOT NULL, ISPUBLIC INTEGER, TITLE VARCHAR2(250) NOT NULL )");
st.executeUpdate("CREATE INDEX IX_SR ON SAVED_REQUESTS (KEY_EM,USER_ID)");
}
try {
st.executeQuery("SELECT 1 FROM XEM_IMPORTS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE XEM_IMPORTS (UTI_LOGIN VARCHAR2(50) not null, IMPORT_ID VARCHAR2(200) not null, FILE_NAME VARCHAR2(200) not null, FILE_TYPE VARCHAR2(200) not null, SUBMIT_DATE TIMESTAMP, END_DATE TIMESTAMP, STATUS integer not null, COLLECTIVITE VARCHAR2(15), BUDGET VARCHAR(24), COLLECTIVITE_LIB VARCHAR(250), BUDGET_LIB VARCHAR(250), ERROR_MESSAGE VARCHAR2(4000), CLEANED integer)");
st.executeUpdate("CREATE INDEX IX_IMPORTS ON XEM_IMPORTS (UTI_LOGIN,IMPORT_ID)");
}
try {
st.executeQuery("SELECT 1 FROM XEM_IMPORTS_FILES").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE XEM_IMPORTS_FILES (IMPORT_ID VARCHAR2(200) not null,SUB_FILE_NAME VARCHAR2(1000) not null,FILE_TYPE VARCHAR2(200) not null,STATUS INTEGER,COLLECTIVITE VARCHAR2(15),BUDGET VARCHAR2(24),COLLECTIVITE_LIB VARCHAR2(250),BUDGET_LIB VARCHAR2(250),ERROR_MESSAGE VARCHAR2(4000))");
st.executeUpdate("CREATE INDEX IX_IMPORTS_FILES ON XEM_IMPORTS_FILES (IMPORT_ID)");
}
try {
st.executeQuery("SELECT 1 FROM EXPORT_JOBS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE EXPORT_JOBS (UTI_LOGIN VARCHAR2(50) not null,EXPORT_ID int NOT NULL, FILE_NAME VARCHAR2(80) not null, EXPORT_NAME VARCHAR2(80) not null, DOC_ID VARCHAR2(150) not null, ETAT_ID VARCHAR2(150) not null, CONFIG_ID int not null, EXPORT_SIZE int, PRIORITY int, EXPORT_STATUS int not null, SUBMIT_DATE TIMESTAMP, RUN_DATE TIMESTAMP, DOWNLOAD_DATE TIMESTAMP, ERROR_MESSAGE VARCHAR2(4000), DRS BLOB not null, CLEANED integer, GENERATED_FILE_NAME VARCHAR2(150), ELEMENT_ID VARCHAR2(150))");
st.executeUpdate("CREATE SEQUENCE SQ_EXPORTS_JOBS START WITH 1 INCREMENT BY 1 NOMAXVALUE");
st.executeUpdate("CREATE INDEX IX_EXPORTS ON EXPORT_JOBS(UTI_LOGIN,EXPORT_ID)");
}
try {
st.executeQuery("SELECT 1 FROM XML_CONFIG_ELEMENTS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE XML_CONFIG_ELEMENTS (UTI_LOGIN VARCHAR2(50) not null, ELEMENT_ID VARCHAR2(50) not null, ELEMENT BLOB)");
st.executeUpdate("CREATE UNIQUE INDEX XML_CFG_IX ON XML_CONFIG_ELEMENTS (UTI_LOGIN, ELEMENT_ID)");
}
try {
st.executeQuery("SELECT 1 FROM IMPORTED_ARCHIVES").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE IMPORTED_ARCHIVES (ARCHIVE_NAME VARCHAR2(100) not null, UTI_LOGIN VARCHAR2(50) not null, IMPORT_DATE TIMESTAMP not null)");
st.executeUpdate("CREATE INDEX IX_IMPORTED_ARCHIVES ON IMPORTED_ARCHIVES (ARCHIVE_NAME)");
}
try {
st.executeQuery("SELECT 1 FROM ATTACHMENTS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE ATTACHMENTS (COLLECTIVITE VARCHAR2(50) NOT NULL, ID_UNIQUE VARCHAR2(200) NOT NULL, IN_ARCHIVE INT, ARCHIVE_NAME VARCHAR2(100), PATH VARCHAR2(250))");
st.executeUpdate("CREATE UNIQUE INDEX IX_ATTACHMENTS ON ATTACHMENTS (COLLECTIVITE, ID_UNIQUE)");
}
try {
st.executeQuery("SELECT 1 FROM PARAMETERS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE PARAMETERS (PARAM_NAME VARCHAR2(100) NOT NULL, PARAM_VALUE VARCHAR2(100))");
st.executeUpdate("CREATE UNIQUE INDEX IX_PARAMETERS ON PARAMETERS (PARAM_NAME)");
}
try {
st.executeQuery("SELECT 1 FROM TRAITEMENT").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE TRAITEMENT (TRT_ID INTEGER NOT NULL, TRT_CLASS VARCHAR(200) NOT NULL, TRT_DESC VARCHAR(150) NOT NULL, TRT_DATE_DEBUT DATE DEFAULT SYSDATE NOT NULL, TRT_DATE_FIN DATE, TRT_CODE_GRAVITE VARCHAR(5), TRT_RESUME VARCHAR(300), TRT_BINARY_DATA BLOB, CONSTRAINT PK_TRAITEMENT PRIMARY KEY (TRT_ID))");
}
if (!st.executeQuery("select 1 from USER_SEQUENCES WHERE SEQUENCE_NAME='SQ_TRAITEMENT'").next()) {
}
try {
st.executeQuery("SELECT 1 FROM MESSAGE_TRAITEMENT").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE MESSAGE_TRAITEMENT (TRT_ID INTEGER NOT NULL, MTR_ID INTEGER NOT NULL, MTR_CODE_GRAVITE VARCHAR(5) NOT NULL, MTR_DATE_DU_MESSAGE DATE DEFAULT SYSDATE, MTR_MESSAGE VARCHAR(300), MTR_CATEGORIE VARCHAR(200), MTR_INFO_COMP VARCHAR(4000), CONSTRAINT PK_MESSAGE_TRAITEMENT PRIMARY KEY (TRT_ID,MTR_ID), CONSTRAINT FK_MESSAGE__LGA_REF_T_TRAITEME FOREIGN KEY (TRT_ID) REFERENCES TRAITEMENT(TRT_ID))");
}
try {
st.executeQuery("SELECT 1 FROM ARCHIVE_BUDGET").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("CREATE TABLE ARCHIVE_BUDGET (IDCOLL VARCHAR(14) NOT NULL, EXERCICE VARCHAR(4) NOT NULL, ARCHIVE_NAME VARCHAR(100) NOT NULL)");
st.executeUpdate("CREATE UNIQUE INDEX ARCHIVE_BUDGET_IX on ARCHIVE_BUDGET(IDCOLL,EXERCICE)");
}
try {
st.executeQuery("SELECT 1 FROM IMPORT_JOBS").close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
st.executeUpdate("create table IMPORT_JOBS(IMPORT_ID NUMBER, ARCHIVE_NAME VARCHAR(150) NOT NULL, EXERCICE VARCHAR(4) NOT NULL, USER_LOGIN VARCHAR(50) NOT NULL, DATE_DEMANDE TIMESTAMP DEFAULT SYSDATE NOT NULL, IMPORT_STATUS int NOT NULL, IMPORT_SCHEME VARCHAR(150) NOT NULL, DATE_MESSAGE DATE, DATE_RAPPEL DATE, DATE_CONFIRM DATE)");
st.executeUpdate("CREATE SEQUENCE SQ_IMPORT_JOBS START WITH 1 INCREMENT BY 1 NOMAXVALUE");
st.executeUpdate("alter table IMPORT_JOBS add constraint PK_IMPORT_JOBS PRIMARY KEY (IMPORT_ID)");
}
st.close();
- DatabaseMetaData dmd = pCon.getMetaData();
- logger.info("driver = " + dmd.getDriverName() + " - " + dmd.getDriverVersion());
- logger.info("database = " + dmd.getDatabaseProductName() + " - " + dmd.getDatabaseProductVersion());
- } catch (Exception t) {
- logger.error("in initConnections()", t);
- StringBuilder sb = new StringBuilder();
+ final DatabaseMetaData dmd = pCon.getMetaData();
+ OracleDataLayer.logger.info("driver = " + dmd.getDriverName() + " - " + dmd.getDriverVersion());
+ OracleDataLayer.logger.info("database = " + dmd.getDatabaseProductName() + " - " + dmd.getDatabaseProductVersion());
+ } catch (final Exception t) {
+ OracleDataLayer.logger.error("in initConnections()", t);
+ final StringBuilder sb = new StringBuilder();
sb.append("Impossible de se connecter au serveur XeMeLios :\npool=").append((props.getProperty("jndi.poolname") != null ? props.getProperty("jndi.poolname") : props.getProperty("database.url")));
throw new DataConfigurationException(sb.toString(), t);
} finally {
@Override
public String getLayerName() {
- return LAYER_NAME;
+ return OracleDataLayer.LAYER_NAME;
}
@Override
- public void registerBudgetCollectivite(DocumentModel dm, Pair codeBudget, Pair collectivite, Pair[] parentCollectivites, String docName, String archiveName, XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public void registerBudgetCollectivite(final DocumentModel dm, final Pair codeBudget, final Pair collectivite, final Pair[] parentCollectivites, final String docName, final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- for (TEtat sec : pc.getEtats()) {
- ensureTablesExists(pc, sec, /* codeBudget, collectivite, */con);
+ for (final TEtat sec : pc.getEtats()) {
+ this.ensureTablesExists(pc, sec, /* codeBudget, collectivite, */con);
}
StringBuilder sb = new StringBuilder();
sb.append("SELECT 1 FROM ").append(pc.getListBcTable().getBaseName()).append(" WHERE " + pc.getBudgetCodeColname() + "=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getInitialDocNameColname() + "=?");
ps.setString(1, codeBudget.key);
ps.setString(2, collectivite.key);
ps.setString(3, docName);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (!rs.next()) {
sb = new StringBuilder();
- StringBuffer binds = new StringBuffer();
- sb.append("INSERT INTO ")
- .append(pc.getListBcTable().getBaseName())
+ final StringBuffer binds = new StringBuffer();
+ sb.append("INSERT INTO ").append(pc.getListBcTable().getBaseName())
.append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + "," + pc.getInitialDocNameColname() + "," + pc.getArchiveNameColname() + "," + pc.getBudgetLibColname() + "," + pc.getCollectiviteLibColname());
binds.append(" VALUES (?,?,?,?,?,?");
for (int i = 0; i < parentCollectivites.length; i++) {
- Pair p = parentCollectivites[i];
- if (p != null && p.key != null && p.libelle != null) {
+ final Pair p = parentCollectivites[i];
+ if ((p != null) && (p.key != null) && (p.libelle != null)) {
sb.append(",PARENT_COLL").append(i + 1).append(",PARENT_COLL").append(i + 1).append("_LIB");
binds.append(",?,?");
}
ps.setString(5, codeBudget.libelle);
ps.setString(6, collectivite.libelle);
int i = 7;
- for (Pair p : parentCollectivites) {
- if (p != null && p.key != null && p.libelle != null) {
+ for (final Pair p : parentCollectivites) {
+ if ((p != null) && (p.key != null) && (p.libelle != null)) {
ps.setString(i++, p.key);
ps.setString(i++, p.libelle);
}
}
ps.executeUpdate();
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Exception t) {
- logger.info("ps closed !", t);
+ } catch (final Exception t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean importElement(DocumentModel dm, EtatModel currentEtat, Pair codeBudget, Pair collectivite, String sourceFileName, String elementName, byte[] data, String encoding, String archiveName, XemeliosUser user)
+ public boolean importElement(final DocumentModel dm, final EtatModel currentEtat, final Pair codeBudget, final Pair collectivite, final String sourceFileName, final String elementName, final byte[] data, final String encoding, final String archiveName, final XemeliosUser user)
throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
- throw new UnauthorizedException(String.format(getMessages().getString(NOT_ALLOWED_ROLE), getMessages().getString(ROLE_IMPORT)));
+ throw new UnauthorizedException(String.format(this.getMessages().getString(MessageEntries.NOT_ALLOWED_ROLE), this.getMessages().getString(MessageEntries.ROLE_IMPORT)));
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
// logger.debug("importing element\n"+strElement);
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
- TEtat sec = pc.getEtat(currentEtat.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
+ final TEtat sec = pc.getEtat(currentEtat.getId());
Connection con = null;
PreparedStatement ps = null;
IndexerHandler ih = null;
String strWarnings = null;
try {
con = PoolManager.getInstance().getConnection();
- ensureTablesExists(pc, sec, /* codeBudget, collectivite, */con);
+ this.ensureTablesExists(pc, sec, /* codeBudget, collectivite, */con);
// inserting document
- StringBuilder sb = new StringBuilder();
- sb.append("INSERT INTO ").append(sec.getDocumentTable().getBaseName())
- .append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + ", " + pc.getInitialDocNameColname() + ", DOC_ID, DOC, " + pc.getArchiveNameColname() + ") VALUES (?,?,?,?,?,?)");
+ final StringBuilder sb = new StringBuilder();
+ sb.append("INSERT INTO ").append(sec.getDocumentTable().getBaseName()).append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + ", " + pc.getInitialDocNameColname() + ", DOC_ID, DOC, " + pc.getArchiveNameColname() + ") VALUES (?,?,?,?,?,?)");
ps = con.prepareStatement(sb.toString());
ps.setString(1, codeBudget.key);
ps.setString(2, collectivite.key);
ps.setString(3, sourceFileName);
ps.setString(4, elementName);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream gzip = new GZIPOutputStream(baos);
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final GZIPOutputStream gzip = new GZIPOutputStream(baos);
gzip.write(data);
gzip.flush();
gzip.close();
- byte[] gzippedBuffer = baos.toByteArray();
- InputStream is = new ByteArrayInputStream(gzippedBuffer);
+ final byte[] gzippedBuffer = baos.toByteArray();
+ final InputStream is = new ByteArrayInputStream(gzippedBuffer);
ps.setBinaryStream(5, is, gzippedBuffer.length);
if (archiveName != null) {
ps.setString(6, archiveName);
// indexing
ih = new IndexerHandler(sec, codeBudget.key, collectivite.key, elementName, con, dm.getNamespaces(), sourceFileName, archiveName);
ih.reset();
- SAXParser parser = saxFactory.newSAXParser();
+ final SAXParser parser = this.saxFactory.newSAXParser();
parser.parse(new ByteArrayInputStream(data), ih);
ih.reset();
strWarnings = ih.getWarnings();
ih = null;
- } catch (SQLException sqlEx) {
- logger.error(sqlEx, sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error(sqlEx, sqlEx);
throw new DataAccessException(sqlEx);
- } catch (SAXException saxEx) {
- logger.error(saxEx, saxEx);
+ } catch (final SAXException saxEx) {
+ OracleDataLayer.logger.error(saxEx, saxEx);
throw new DataAccessException(ih.getException() != null ? ih.getException() : saxEx);
- } catch (ParserConfigurationException pcEx) {
- logger.error(pcEx, pcEx);
+ } catch (final ParserConfigurationException pcEx) {
+ OracleDataLayer.logger.error(pcEx, pcEx);
throw new DataConfigurationException(pcEx);
- } catch (IOException ioEx) {
- logger.error(ioEx, ioEx);
+ } catch (final IOException ioEx) {
+ OracleDataLayer.logger.error(ioEx, ioEx);
throw new DataAccessException(ih.getException() != null ? ih.getException() : ioEx);
- } catch (Exception t) {
- logger.error(t, t);
+ } catch (final Exception t) {
+ OracleDataLayer.logger.error(t, t);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
}
if (strWarnings != null) {
- StringBuilder sb = warnings.get(Thread.currentThread());
+ StringBuilder sb = this.warnings.get(Thread.currentThread());
if (sb == null) {
sb = new StringBuilder();
- warnings.put(Thread.currentThread(), sb);
+ this.warnings.put(Thread.currentThread(), sb);
}
sb.append(strWarnings);
}
}
@Override
- public boolean saveRepository(DocumentModel dm, Pair collectivite, Document repository, Pair nomenclatureReference, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean saveRepository(final DocumentModel dm, final Pair collectivite, final Document repository, final Pair nomenclatureReference, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
if (pc.getRepositoryTable() == null) {
return false;
}
try {
con = PoolManager.getInstance().getConnection();
// String repositoryEncoding = repository.getXmlEncoding();
- Transformer trans = FactoryProvider.getTransformerFactory().newTransformer();
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- GZIPOutputStream gzip = new GZIPOutputStream(baos);
- StreamResult sr = new StreamResult(gzip);
+ final Transformer trans = FactoryProvider.getTransformerFactory().newTransformer();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final GZIPOutputStream gzip = new GZIPOutputStream(baos);
+ final StreamResult sr = new StreamResult(gzip);
trans.transform(new DOMSource(repository), sr);
gzip.flush();
gzip.close();
- StringBuilder sb = new StringBuilder();
- if (!doesRepositoryExist(pc, collectivite.key, con, (nomenclatureReference != null ? nomenclatureReference.key : null))) {
+ final StringBuilder sb = new StringBuilder();
+ if (!this.doesRepositoryExist(pc, collectivite.key, con, (nomenclatureReference != null ? nomenclatureReference.key : null))) {
sb.append("INSERT INTO ").append(pc.getRepositoryTable().getBaseName()).append(" (LIBELLE,REPOSITORY," + pc.getCollectiviteCodeColname() + ",ID) VALUES (?,?,?,?)");
updateMode = UPDATES_MODES.INSERT;
} else {
sb.append("UPDATE ").append(pc.getRepositoryTable().getBaseName()).append(" SET LIBELLE=?, REPOSITORY=? WHERE " + pc.getCollectiviteCodeColname() + "=? AND ID");
updateMode = UPDATES_MODES.UPDATE;
- if (nomenclatureReference == null || nomenclatureReference.key == null) {
+ if ((nomenclatureReference == null) || (nomenclatureReference.key == null)) {
sb.append(" IS NULL");
} else {
sb.append("=?");
}
}
ps = con.prepareStatement(sb.toString());
- byte[] buffer = baos.toByteArray();
- ByteArrayInputStream is = new ByteArrayInputStream(buffer);
- if (nomenclatureReference != null && nomenclatureReference.libelle != null) {
+ final byte[] buffer = baos.toByteArray();
+ final ByteArrayInputStream is = new ByteArrayInputStream(buffer);
+ if ((nomenclatureReference != null) && (nomenclatureReference.libelle != null)) {
ps.setString(1, nomenclatureReference.libelle);
} else {
ps.setNull(1, Types.VARCHAR);
}
ps.setBinaryStream(2, is, buffer.length);
ps.setString(3, collectivite.key);
- if (nomenclatureReference != null && nomenclatureReference.key != null) {
+ if ((nomenclatureReference != null) && (nomenclatureReference.key != null)) {
ps.setString(4, nomenclatureReference.key);
} else if (updateMode == UPDATES_MODES.INSERT) {
ps.setNull(4, Types.VARCHAR);
}
- int modifiedRows = ps.executeUpdate();
+ final int modifiedRows = ps.executeUpdate();
bRet = (modifiedRows == 1);
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (TransformerException tEx) {
+ } catch (final TransformerException tEx) {
throw new DataConfigurationException(tEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Exception t) {
- logger.info("ps closed !", t);
+ } catch (final Exception t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public void removeDocument(DocumentModel dm, Pair budget, Pair collectivite, String docName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public void removeDocument(final DocumentModel dm, final Pair budget, final Pair collectivite, final String docName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
// index
// documents
con = PoolManager.getInstance().getConnection();
- for (TEtat sec : pc.getEtats()) {
- ensureTablesExists(pc, sec, /* budget, collectivite, */con);
+ for (final TEtat sec : pc.getEtats()) {
+ this.ensureTablesExists(pc, sec, /* budget, collectivite, */con);
StringBuilder sql = null;
- for (TTable ixTable : sec.getIndexTables()) {
+ for (final TTable ixTable : sec.getIndexTables()) {
sql = new StringBuilder();
- sql.append("DELETE FROM ").append(ixTable.getBaseName()).append(" WHERE ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname())
- .append("=?");
+ sql.append("DELETE FROM ").append(ixTable.getBaseName()).append(" WHERE ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
// delete from special keys
if (pc.getSpecialKeyTable() != null) {
sql = new StringBuilder();
- sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
}
// delete from documents
sql = new StringBuilder();
- sql.append("delete from ").append(sec.getDocumentTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(sec.getDocumentTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.executeUpdate();
// delete from list bud/coll
sql = new StringBuilder();
- sql.append("delete from ").append(pc.getListBcTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ")
- .append(pc.getInitialDocNameColname()).append("=?");
+ sql.append("delete from ").append(pc.getListBcTable().getBaseName()).append(" where ").append(pc.getCollectiviteCodeColname()).append("=? AND ").append(pc.getBudgetCodeColname()).append("=? AND ").append(pc.getInitialDocNameColname()).append("=?");
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.setString(3, docName);
ps.executeUpdate();
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Exception t) {
- logger.info("ps closed !", t);
+ } catch (final Exception t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean isDocumentExists(DocumentModel dm, Pair budget, Pair collectivite, String docName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean isDocumentExists(final DocumentModel dm, final Pair budget, final Pair collectivite, final String docName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!(user.hasRole(XemeliosUser.ROLE_IMPORT) || user.hasRole(XemeliosUser.ROLE_SEARCH))) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
boolean ret = false;
try {
con = PoolManager.getInstance().getConnection();
- for (TEtat sec : pc.getEtats()) {
- ensureTablesExists(pc, sec, /* budget, collectivite, */con);
- ret |= documentExists(pc, budget, collectivite, docName, con);
+ for (final TEtat sec : pc.getEtats()) {
+ this.ensureTablesExists(pc, sec, /* budget, collectivite, */con);
+ ret |= this.documentExists(pc, budget, collectivite, docName, con);
if (ret) {
return true;
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (con != null) {
}
@Override
- public void saveSpecialKeys(DocumentModel dm, Pair budget, Pair collectivite, String docName, String archiveName, Pair sk1, Pair sk2, Pair sk3, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public void saveSpecialKeys(final DocumentModel dm, final Pair budget, final Pair collectivite, final String docName, final String archiveName, final Pair sk1, final Pair sk2, final Pair sk3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des fichiers");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à importer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- if (sk1 == null && sk2 == null && sk3 == null) {
+ if ((sk1 == null) && (sk2 == null) && (sk3 == null)) {
return;
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- for (TEtat sec : pc.getEtats()) {
- ensureTablesExists(pc, sec, /* budget, collectivite, */con);
+ for (final TEtat sec : pc.getEtats()) {
+ this.ensureTablesExists(pc, sec, /* budget, collectivite, */con);
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("INSERT INTO ").append(pc.getSpecialKeyTable().getBaseName())
.append(" (" + pc.getBudgetCodeColname() + "," + pc.getCollectiviteCodeColname() + "," + pc.getInitialDocNameColname() + "," + pc.getArchiveNameColname() + ",KEY1,LIB1,KEY2,LIB2,KEY3,LIB3) VALUES(?,?,?,?,?,?,?,?,?,?)");
ps = con.prepareStatement(sb.toString());
ps.setNull(10, Types.VARCHAR);
}
ps.executeUpdate();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean canSearch(DocumentModel dm, EtatModel em, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean canSearch(final DocumentModel dm, final EtatModel em, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre());
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
- TEtat sec = pc.getEtat(em.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
+ final TEtat sec = pc.getEtat(em.getId());
Connection con = null;
- PreparedStatement ps = null;
+ final PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
ResultSet rs = null;
try {
rs = con.createStatement().executeQuery("SELECT 1 FROM " + sec.getDocumentTable().getBaseName() + " WHERE ROWNUM=1");
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
// table doesn't exists
return false;
}
return rs.next();
}
return false;
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<Pair> getSpecialKeys1(DocumentModel dm, Pair collectivite, Pair budget, boolean distinct, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getSpecialKeys1(final DocumentModel dm, final Pair collectivite, final Pair budget, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY1,LIB1 FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
- PreparedStatement ps = con.prepareStatement(sb.toString());
+ final PreparedStatement ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
vRet.add(new Pair(rs.getString(1), rs.getString(2)));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (con != null) {
}
@Override
- public Vector<Pair> getSpecialKeys2(DocumentModel dm, Pair collectivite, Pair budget, Pair key1, boolean distinct, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getSpecialKeys2(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY2,LIB2 FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE KEY1=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY2 is not null");
+ final StringBuilder sb = new StringBuilder();
+ sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY2,LIB2 FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE KEY1=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY2 is not null");
ps = con.prepareStatement(sb.toString());
ps.setString(1, key1.key);
ps.setString(2, collectivite.key);
ps.setString(3, budget.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
vRet.add(new Pair(rs.getString(1), rs.getString(2)));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<Pair> getSpecialKeys3(DocumentModel dm, Pair collectivite, Pair budget, Pair key1, Pair key2, boolean distinct, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getSpecialKeys3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final boolean distinct, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY3,LIB3 FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE KEY1=? AND KEY2=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
+ final StringBuilder sb = new StringBuilder();
+ sb.append("SELECT ").append(distinct ? "DISTINCT " : " ").append("KEY3,LIB3 FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE KEY1=? AND KEY2=? AND " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, key1.key);
ps.setString(2, key2.key);
ps.setString(3, collectivite.key);
ps.setString(4, budget.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
vRet.add(new Pair(rs.getString(1), rs.getString(2)));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<Pair> getParentCollectivites(DocumentModel dm, int level, Pair[] otherParents, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getParentCollectivites(final DocumentModel dm, final int level, final Pair[] otherParents, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
- TreeSet<Pair> vRet = new TreeSet<Pair>(new Comparator<Pair>() {
+ final TreeSet<Pair> vRet = new TreeSet<Pair>(new Comparator<Pair>() {
@Override
- public int compare(Pair o1, Pair o2) {
+ public int compare(final Pair o1, final Pair o2) {
int ret = o1.libelle.compareTo(o2.libelle);
if (ret == 0) {
ret = o1.key.compareTo(o2.key);
return ret;
}
});
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT PARENT_COLL").append(level).append(", PARENT_COLL").append(level).append("_LIB, " + pc.getCollectiviteCodeColname() + " FROM ").append(pc.getListBcTable().getBaseName());
sb.append(" WHERE PARENT_COLL").append(level).append(" IS NOT NULL AND ");
- if (otherParents != null && otherParents.length > 0) {
+ if ((otherParents != null) && (otherParents.length > 0)) {
for (int i = 0; i < otherParents.length; i++) {
- Pair p = otherParents[i];
+ final Pair p = otherParents[i];
if (p != null) {
sb.append("PARENT_COLL").append(level + 1 + i).append("=? ");
sb.append("AND ");
sb.delete(sb.length() - 7, sb.length());
}
sb.append(" ORDER BY PARENT_COLL").append(level).append("_LIB ASC");
- logger.debug(sb.toString());
+ OracleDataLayer.logger.debug(sb.toString());
ps = con.prepareStatement(sb.toString());
- if (otherParents != null && otherParents.length > 0) {
+ if ((otherParents != null) && (otherParents.length > 0)) {
int j = 1;
- for (int i = 0; i < otherParents.length; i++) {
- if (otherParents[i] != null) {
- ps.setString(j++, otherParents[i].key);
+ for (final Pair otherParent : otherParents) {
+ if (otherParent != null) {
+ ps.setString(j++, otherParent.key);
}
}
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
- Pair parentColl = new Pair(rs.getString(1), rs.getString(2));
+ final Pair parentColl = new Pair(rs.getString(1), rs.getString(2));
if (user.hasCollectivite(rs.getString(3), dm)) {
vRet.add(parentColl);
}
}
rs.close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
}
}
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
}
- Vector<Pair> v = new Vector<Pair>();
+ final Vector<Pair> v = new Vector<Pair>();
v.addAll(vRet);
return v;
}
@Override
- public int getCollectivitesCount(DocumentModel dm, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public int getCollectivitesCount(final DocumentModel dm, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
int ret = 0;
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT distinct(" + pc.getCollectiviteCodeColname() + ") FROM ").append(pc.getListBcTable().getBaseName());
- ResultSet rs = con.createStatement().executeQuery(sb.toString());
+ final ResultSet rs = con.createStatement().executeQuery(sb.toString());
while (rs.next()) {
- String collectivite = rs.getString(1);
+ final String collectivite = rs.getString(1);
if (user.hasCollectivite(collectivite, dm)) {
ret++;
}
}
rs.close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (con != null) {
}
@Override
- public Vector<Pair> getCollectivites(DocumentModel dm, Pair[] parents, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getCollectivites(final DocumentModel dm, final Pair[] parents, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT " + pc.getCollectiviteCodeColname() + ", " + pc.getCollectiviteLibColname() + " FROM ").append(pc.getListBcTable().getBaseName());
- if (parents != null && parents.length > 0 && parents[0] != null) {
+ if ((parents != null) && (parents.length > 0) && (parents[0] != null)) {
sb.append(" WHERE ");
for (int i = 0; i < parents.length; i++) {
if (parents[i] != null) {
}
sb.append(" ORDER BY " + pc.getCollectiviteLibColname());
ps = con.prepareStatement(sb.toString());
- if (parents != null && parents.length > 0 && parents[0] != null) {
+ if ((parents != null) && (parents.length > 0) && (parents[0] != null)) {
for (int i = 0; i < parents.length; i++) {
if (parents[i] != null) {
ps.setString(i + 1, parents[i].key);
}
}
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
- Pair collectivite = new Pair(rs.getString(1), rs.getString(2));
+ final Pair collectivite = new Pair(rs.getString(1), rs.getString(2));
if (user.hasCollectivite(collectivite.key, dm)) {
vRet.add(collectivite);
}
}
rs.close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException ex) {
+ } catch (final SQLException ex) {
}
}
if (con != null) {
}
@Override
- public Vector<Pair> getArchivesImported(XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getArchivesImported(final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
- Vector<Pair> vRet = new Vector<Pair>();
+ final Vector<Pair> vRet = new Vector<Pair>();
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT UTI_LOGIN, ARCHIVE_NAME FROM IMPORTED_ARCHIVES");
sb.append(" ORDER BY ARCHIVE_NAME");
ps = con.prepareStatement(sb.toString());
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
- Pair archive = new Pair(rs.getString(1), rs.getString(2));
+ final Pair archive = new Pair(rs.getString(1), rs.getString(2));
vRet.add(archive);
}
rs.close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException ex) {
+ } catch (final SQLException ex) {
}
}
if (con != null) {
}
@Override
- public Vector<Pair> getBudgets(DocumentModel dm, Pair collectivite, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getBudgets(final DocumentModel dm, final Pair collectivite, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- if (dm == null || collectivite == null) {
+ final Vector<Pair> vRet = new Vector<Pair>();
+ if ((dm == null) || (collectivite == null)) {
return vRet;
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT DISTINCT " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + " FROM ").append(pc.getListBcTable().getBaseName())
- .append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ORDER BY " + pc.getBudgetLibColname());
+ final StringBuilder sb = new StringBuilder();
+ sb.append("SELECT DISTINCT " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + " FROM ").append(pc.getListBcTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ORDER BY " + pc.getBudgetLibColname());
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
vRet.add(new Pair(rs.getString(1), rs.getString(2)));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<String> getBudgetsAnnexes(DocumentModel dm, EtatModel em, Pair collectivite, Pair budget, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<String> getBudgetsAnnexes(final DocumentModel dm, final EtatModel em, final Pair collectivite, final Pair budget, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<String> vRet = new Vector<String>();
- if (dm == null || collectivite == null) {
+ final Vector<String> vRet = new Vector<String>();
+ if ((dm == null) || (collectivite == null)) {
return vRet;
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
- TEtat pEtat = pc.getEtat(em.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
+ final TEtat pEtat = pc.getEtat(em.getId());
// TODO: checker la façon de choisir la table d'index
- TTable tableIndex = pEtat.getIndexTables().iterator().next();
+ final TTable tableIndex = pEtat.getIndexTables().iterator().next();
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT BUDGET_BA, SIRET_BA FROM ").append(tableIndex.getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? ORDER BY DOC_ID");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
vRet.add(rs.getString(2));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
}
- int videPos = vRet.indexOf("");
+ final int videPos = vRet.indexOf("");
vRet.remove(videPos);
return vRet;
}
@Override
- public Collection<Pair> queryRepository(DocumentModel dm, Pair collectivite, RecherchePaireModel rpm, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Collection<Pair> queryRepository(final DocumentModel dm, final Pair collectivite, final RecherchePaireModel rpm, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
Document repository;
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- repository = parseDOMFromInputStream(domFactory, docIn);
+ repository = this.parseDOMFromInputStream(this.domFactory, docIn);
} finally {
docIn.close();
}
- XPath xp = xPathFactory.newXPath();
+ final XPath xp = this.xPathFactory.newXPath();
xp.setNamespaceContext(dm.getNamespaces());
- DomPath dpCode = rpm.getCodePath().getDomPath(dm.getNamespaces());
- DomPath dpLibelle = rpm.getLibellePath().getDomPath(dm.getNamespaces());
- Object o = xp.evaluate(rpm.getPath().getPath(), repository, XPathConstants.NODESET);
+ final DomPath dpCode = rpm.getCodePath().getDomPath(dm.getNamespaces());
+ final DomPath dpLibelle = rpm.getLibellePath().getDomPath(dm.getNamespaces());
+ final Object o = xp.evaluate(rpm.getPath().getPath(), repository, XPathConstants.NODESET);
if (o instanceof NodeList) {
- NodeList nl = (NodeList) o;
+ final NodeList nl = (NodeList) o;
for (int i = 0; i < nl.getLength(); i++) {
- Node node = nl.item(i);
- String code = (String) dpCode.getValue(node, false);
- String libelle = (String) dpLibelle.getValue(node, true);
+ final Node node = nl.item(i);
+ final String code = (String) dpCode.getValue(node, false);
+ final String libelle = (String) dpLibelle.getValue(node, true);
vRet.add(new Pair(code, libelle));
}
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
- } catch (ParserConfigurationException pcEx) {
+ } catch (final ParserConfigurationException pcEx) {
throw new DataConfigurationException(pcEx);
- } catch (SAXException saxEx) {
+ } catch (final SAXException saxEx) {
throw new DataAccessException(saxEx);
- } catch (XPathExpressionException xpEx) {
+ } catch (final XPathExpressionException xpEx) {
throw new DataConfigurationException(xpEx);
- } catch (InvalidPathExpressionException ipeEx) {
+ } catch (final InvalidPathExpressionException ipeEx) {
throw new DataConfigurationException(ipeEx);
- } catch (PathNotFoundException pnfEx) {
+ } catch (final PathNotFoundException pnfEx) {
throw new DataConfigurationException(pnfEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Collection<Pair> queryRepository(DocumentModel dm, Pair collectivite, RecherchePaireModel rpm, Pair refNomenclature, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Collection<Pair> queryRepository(final DocumentModel dm, final Pair collectivite, final RecherchePaireModel rpm, final Pair refNomenclature, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND ID=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- if (refNomenclature != null && refNomenclature.key != null) {
+ if ((refNomenclature != null) && (refNomenclature.key != null)) {
ps.setString(2, refNomenclature.key);
} else {
ps.setNull(2, Types.VARCHAR);
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
Document repository;
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- repository = parseDOMFromInputStream(domFactory, docIn);
+ repository = this.parseDOMFromInputStream(this.domFactory, docIn);
} finally {
docIn.close();
}
- XPath xp = xPathFactory.newXPath();
+ final XPath xp = this.xPathFactory.newXPath();
xp.setNamespaceContext(dm.getNamespaces());
- Object resp = xp.evaluate(rpm.getPath().getPath(), repository, XPathConstants.NODESET);
- DomPath dpCode = rpm.getCodePath().getDomPath(dm.getNamespaces());
- DomPath dpLibelle = rpm.getLibellePath().getDomPath(dm.getNamespaces());
+ final Object resp = xp.evaluate(rpm.getPath().getPath(), repository, XPathConstants.NODESET);
+ final DomPath dpCode = rpm.getCodePath().getDomPath(dm.getNamespaces());
+ final DomPath dpLibelle = rpm.getLibellePath().getDomPath(dm.getNamespaces());
if (resp instanceof NodeList) {
- NodeList nl = (NodeList) resp;
+ final NodeList nl = (NodeList) resp;
for (int i = 0; i < nl.getLength(); i++) {
- Node node = nl.item(i);
- String code = (String) dpCode.getValue(node, false);
- String libelle = (String) dpLibelle.getValue(node, true);
+ final Node node = nl.item(i);
+ final String code = (String) dpCode.getValue(node, false);
+ final String libelle = (String) dpLibelle.getValue(node, true);
vRet.add(new Pair(code, libelle));
}
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
- } catch (ParserConfigurationException pcEx) {
+ } catch (final ParserConfigurationException pcEx) {
throw new DataConfigurationException(pcEx);
- } catch (SAXException saxEx) {
+ } catch (final SAXException saxEx) {
throw new DataAccessException(saxEx);
- } catch (XPathExpressionException xpEx) {
+ } catch (final XPathExpressionException xpEx) {
throw new DataConfigurationException(xpEx);
- } catch (InvalidPathExpressionException ipeEx) {
+ } catch (final InvalidPathExpressionException ipeEx) {
throw new DataConfigurationException(ipeEx);
- } catch (PathNotFoundException pnfEx) {
+ } catch (final PathNotFoundException pnfEx) {
throw new DataConfigurationException(pnfEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public String getRepository(DocumentModel dm, Pair collectivite, Pair budget, String idNomenclature, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public String getRepository(final DocumentModel dm, final Pair collectivite, final Pair budget, final String idNomenclature, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
String ret = null;
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND ");
if (idNomenclature != null) {
sb.append("ID=?");
if (idNomenclature != null) {
ps.setString(2, idNomenclature);
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(docIn, baos);
ret = new String(baos.toByteArray());
docIn.close();
}
- if ("true".equals(getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
- logger.debug(ret);
+ if ("true".equals(this.getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
+ OracleDataLayer.logger.debug(ret);
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<String> getRepositorys(DocumentModel dm, Pair collectivite, Pair budget, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<String> getRepositorys(final DocumentModel dm, final Pair collectivite, final Pair budget, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<String> ret = new Vector<String>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<String> ret = new Vector<String>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copy(docIn, baos);
ret.add(new String(baos.toByteArray()));
docIn.close();
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Document getRepositoryAsDom(DocumentModel dm, Pair collectivite, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- return getRepositoryAsDom(dm, collectivite, null, user);
+ public Document getRepositoryAsDom(final DocumentModel dm, final Pair collectivite, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ return this.getRepositoryAsDom(dm, collectivite, null, user);
}
@Override
- public Document getRepositoryAsDom(DocumentModel dm, Pair collectivite, String idNomenclature, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Document getRepositoryAsDom(final DocumentModel dm, final Pair collectivite, final String idNomenclature, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> vRet = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> vRet = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
if (pc.getRepositoryTable() == null) {
return null;
}
Document repository = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND ");
if (idNomenclature != null) {
sb.append("ID=?");
if (idNomenclature != null) {
ps.setString(2, idNomenclature);
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- repository = parseDOMFromInputStream(domFactory, docIn);
+ repository = this.parseDOMFromInputStream(this.domFactory, docIn);
} finally {
docIn.close();
}
- if ("true".equals(getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
- TransformerFactory tf = FactoryProvider.getTransformerFactory();
- Transformer t = tf.newTransformer();
- ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+ if ("true".equals(this.getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
+ final TransformerFactory tf = FactoryProvider.getTransformerFactory();
+ final Transformer t = tf.newTransformer();
+ final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
t.transform(new DOMSource(repository), new StreamResult(baos2));
- logger.debug(new String(baos2.toByteArray()));
+ OracleDataLayer.logger.debug(new String(baos2.toByteArray()));
}
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
throw new DataConfigurationException("invalid code !", t);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Collection<String> getDistinctValues(ElementModel em, Pair collectivite, Pair budget, String path, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Collection<String> getDistinctValues(final ElementModel em, final Pair collectivite, final Pair budget, final String path, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre());
}
if (!user.hasCollectivite(collectivite.key, em.getParent().getParent())) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(em.getParent().getParent(), user).getLayer(getLayerName()).getDocument(em.getParent().getParent().getId());
- TEtat sec = pc.getEtat(em.getParent().getId());
- TSqlIndex si = sec.getSqlIndexByPath(path);
- TTable sti = sec.getIndexTable(si.getTableId());
- StringBuilder sb = new StringBuilder();
+ final TDocument pc = this.getPersistenceConfig(em.getParent().getParent(), user).getLayer(this.getLayerName()).getDocument(em.getParent().getParent().getId());
+ final TEtat sec = pc.getEtat(em.getParent().getId());
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
+ final TTable sti = sec.getIndexTable(si.getTableId());
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DISTINCT(").append(si.getColumn()).append(") FROM ").append(sti.getBaseName()).append(" ");
- sb.append("WHERE " + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND " + pc.getBudgetCodeColname() + "='").append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ")
- .append(si.getColumn()).append(" IS NOT NULL ORDER BY 1");
+ sb.append("WHERE " + pc.getCollectiviteCodeColname() + "='").append(StringEscapeUtils.escapeSql(collectivite.key)).append("' AND " + pc.getBudgetCodeColname() + "='").append(StringEscapeUtils.escapeSql(budget.key)).append("' AND ").append(si.getColumn()).append(" IS NOT NULL ORDER BY 1");
- Vector<String> vRet = new Vector<String>();
+ final Vector<String> vRet = new Vector<String>();
Connection con = null;
Statement st = null;
try {
con = PoolManager.getInstance().getConnection();
st = con.createStatement();
- ResultSet rs = st.executeQuery(sb.toString());
+ final ResultSet rs = st.executeQuery(sb.toString());
while (rs.next()) {
vRet.add(rs.getString(1));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataConfigurationException("invalid code !", sqlEx);
} finally {
if (st != null) {
try {
st.close();
- } catch (Throwable t) {
- logger.info("st closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("st closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeDocumentModel(DocumentModel dm, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeDocumentModel(final DocumentModel dm, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
Statement st = null;
try {
con = PoolManager.getInstance().getConnection();
StringBuilder sql = null;
- for (TEtat sec : pc.getEtats()) {
- ensureTablesExists(pc, sec, /* null, null, */con);
+ for (final TEtat sec : pc.getEtats()) {
+ this.ensureTablesExists(pc, sec, /* null, null, */con);
// delete from index
- for (TTable sti : sec.getIndexTables()) {
+ for (final TTable sti : sec.getIndexTables()) {
sql = new StringBuilder();
sql.append("delete from ").append(sti.getBaseName());
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
st = con.createStatement();
st.executeUpdate(sql.toString());
sql = new StringBuilder();
// delete from special keys
if (pc.getSpecialKeyTable() != null) {
sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName());
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
st.executeUpdate(sql.toString());
}
// delete from documents
sql = new StringBuilder();
sql.append("delete from ").append(sec.getDocumentTable().getBaseName());
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
st.executeUpdate(sql.toString());
}
// delete from list bud/coll
sql = new StringBuilder();
sql.append("delete from ").append(pc.getListBcTable().getBaseName());
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
st.executeUpdate(sql.toString());
// delete from repository (it is the only case)
if (pc.getRepositoryTable() != null) {
sql = new StringBuilder();
sql.append("delete from ").append(pc.getRepositoryTable().getBaseName());
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
st.executeUpdate(sql.toString());
st.close();
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (st != null) {
try {
st.close();
- } catch (Throwable t) {
- logger.info("st closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("st closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeCollectivite(DocumentModel dm, Pair collectivite, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeCollectivite(final DocumentModel dm, final Pair collectivite, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
Statement st = null;
try {
con = PoolManager.getInstance().getConnection();
st = con.createStatement();
- ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
- ArrayList<String> existingTables = new ArrayList<String>();
+ final ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
+ final ArrayList<String> existingTables = new ArrayList<String>();
while (rs.next()) {
existingTables.add(rs.getString(1));
}
// delete from special keys
if (pc.getSpecialKeyTable() != null) {
if (existingTables.contains(pc.getSpecialKeyTable().getBaseName())) {
- logger.debug("delete from " + pc.getSpecialKeyTable().getBaseName());
+ OracleDataLayer.logger.debug("delete from " + pc.getSpecialKeyTable().getBaseName());
sql = new StringBuilder();
sql.append("delete from ").append(pc.getSpecialKeyTable().getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sql.toString());
}
// delete from list bud/coll
if (existingTables.contains(pc.getListBcTable().getBaseName())) {
- logger.debug("delete from " + pc.getListBcTable().getBaseName());
+ OracleDataLayer.logger.debug("delete from " + pc.getListBcTable().getBaseName());
sql = new StringBuilder();
sql.append("delete from ").append(pc.getListBcTable().getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sql.toString());
// delete from repository (it is the only case)
if (pc.getRepositoryTable() != null) {
if (existingTables.contains(pc.getRepositoryTable().getBaseName())) {
- logger.debug("delete from " + pc.getRepositoryTable().getBaseName());
+ OracleDataLayer.logger.debug("delete from " + pc.getRepositoryTable().getBaseName());
sql = new StringBuilder();
sql.append("delete from ").append(pc.getRepositoryTable().getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sql.toString());
ps.executeUpdate();
}
}
- for (TEtat sec : pc.getEtats()) {
+ for (final TEtat sec : pc.getEtats()) {
// delete from index
- for (TTable sti : sec.getIndexTables()) {
+ for (final TTable sti : sec.getIndexTables()) {
if (existingTables.contains(sti.getBaseName())) {
- logger.debug("delete from " + sti.getBaseName());
+ OracleDataLayer.logger.debug("delete from " + sti.getBaseName());
sql = new StringBuilder();
sql.append("delete from ").append(sti.getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sql.toString());
}
// delete from documents
if (existingTables.contains(sec.getDocumentTable().getBaseName())) {
- logger.debug("delete from " + sec.getDocumentTable().getBaseName());
+ OracleDataLayer.logger.debug("delete from " + sec.getDocumentTable().getBaseName());
sql = new StringBuilder();
sql.append("delete from ").append(sec.getDocumentTable().getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sql.toString());
ps = con.prepareStatement(sql.toString());
ps.setString(1, collectivite.key);
ps.executeUpdate();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (st != null) {
try {
st.close();
- } catch (Throwable t) {
- logger.info("st closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("st closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeBudget(DocumentModel dm, Pair collectivite, Pair budget, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeBudget(final DocumentModel dm, final Pair collectivite, final Pair budget, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
Statement st = null;
try {
con = PoolManager.getInstance().getConnection();
st = con.createStatement();
- ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
- ArrayList<String> existingTables = new ArrayList<String>();
+ final ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
+ final ArrayList<String> existingTables = new ArrayList<String>();
while (rs.next()) {
existingTables.add(rs.getString(1));
}
ps.setString(2, budget.key);
ps.executeUpdate();
}
- for (TEtat sec : pc.getEtats()) {
+ for (final TEtat sec : pc.getEtats()) {
// delete from index
- for (TTable sti : sec.getIndexTables()) {
+ for (final TTable sti : sec.getIndexTables()) {
if (existingTables.contains(sti.getBaseName())) {
sql = new StringBuilder();
sql.append("delete from ").append(sti.getBaseName()).append(" where " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=?");
ps.executeUpdate();
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (st != null) {
try {
st.close();
- } catch (Throwable t) {
- logger.info("st closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("st closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeFichier(DocumentModel dm, String fichier, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeFichier(final DocumentModel dm, final String fichier, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
if (!user.hasDocument(dm.getId())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
Statement st = null;
try {
con = PoolManager.getInstance().getConnection();
st = con.createStatement();
- ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
- ArrayList<String> existingTables = new ArrayList<String>();
+ final ResultSet rs = st.executeQuery("SELECT TABLE_NAME FROM TABLES_VERSIONS");
+ final ArrayList<String> existingTables = new ArrayList<String>();
while (rs.next()) {
existingTables.add(rs.getString(1));
}
ps.setString(1, fichier);
ps.executeUpdate();
}
- for (TEtat sec : pc.getEtats()) {
+ for (final TEtat sec : pc.getEtats()) {
// delete from index
- for (TTable sti : sec.getIndexTables()) {
+ for (final TTable sti : sec.getIndexTables()) {
if (existingTables.contains(sti.getBaseName())) {
sql = new StringBuilder();
sql.append("delete from ").append(sti.getBaseName()).append(" where " + pc.getInitialDocNameColname() + "=?");
ps.executeUpdate();
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (st != null) {
try {
st.close();
- } catch (Throwable t) {
- logger.info("st closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("st closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeArchive(HashMap<String, DocumentModel> dms, String archiveName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeArchive(final HashMap<String, DocumentModel> dms, final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données.");
}
// Suppression des données à partir des docId du manifeste
try {
con = PoolManager.getInstance().getConnection();
- for (DocumentModel dm : dms.values()) {
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
- for (Iterator<TEtat> etats = pc.getEtats().iterator(); etats.hasNext();) {
- TEtat etat = etats.next();
+ for (final DocumentModel dm : dms.values()) {
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
+ for (final TEtat etat : pc.getEtats()) {
// Suppression des documents index
- for (TTable table : pc.getEtat(etat.getId()).getIndexTables()) {
- StringBuilder sb = new StringBuilder();
+ for (final TTable table : pc.getEtat(etat.getId()).getIndexTables()) {
+ final StringBuilder sb = new StringBuilder();
sb.append("DELETE FROM ").append(table.getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- logger.debug(sb.toString());
+ OracleDataLayer.logger.debug(sb.toString());
ps = con.prepareStatement(sb.toString());
ps.setString(1, archiveName);
ps.close();
}
// Suppression des documents de l'etat
- StringBuilder queryDocument = new StringBuilder();
+ final StringBuilder queryDocument = new StringBuilder();
queryDocument.append("DELETE FROM ").append(pc.getEtat(etat.getId()).getDocumentTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- logger.debug(queryDocument.toString());
+ OracleDataLayer.logger.debug(queryDocument.toString());
ps = con.prepareStatement(queryDocument.toString());
ps.setString(1, archiveName);
ps.executeUpdate();
ps.close();
// Suppression des budegt/collectivite du doc
- StringBuilder queryBc = new StringBuilder();
+ final StringBuilder queryBc = new StringBuilder();
queryBc.append("DELETE FROM ").append(pc.getListBcTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- logger.debug(queryBc.toString());
+ OracleDataLayer.logger.debug(queryBc.toString());
ps = con.prepareStatement(queryBc.toString());
ps.setString(1, archiveName);
ps.executeUpdate();
}
// Suppression des special keys du doc
if (pc.getSpecialKeyTable() != null) {
- StringBuilder querySps = new StringBuilder();
+ final StringBuilder querySps = new StringBuilder();
querySps.append("DELETE FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE ARCHIVE_NAME = ?");
- logger.debug(querySps.toString());
+ OracleDataLayer.logger.debug(querySps.toString());
ps = con.prepareStatement(querySps.toString());
ps.setString(1, archiveName);
ps.executeUpdate();
ps.setString(1, archiveName);
ps.executeUpdate();
ps.close();
- } catch (Throwable t) {
- logger.error(t);
+ con.commit();
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.error(t);
throw new DataConfigurationException("Problème lors de la suppression des données de l'archive !", t);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("can not close ps !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("can not close ps !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeSpecialKey1(DocumentModel dm, Pair collectivite, Pair budget, Pair key1, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeSpecialKey1(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.setString(3, key1.key);
- ResultSet rs = ps.executeQuery();
- TreeSet<String> al = new TreeSet<String>();
+ final ResultSet rs = ps.executeQuery();
+ final TreeSet<String> al = new TreeSet<String>();
while (rs.next()) {
al.add(rs.getString(1));
}
- for (String docName : al) {
- removeDocument(dm, budget, collectivite, docName, user);
+ for (final String docName : al) {
+ this.removeDocument(dm, budget, collectivite, docName, user);
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeSpecialKey2(DocumentModel dm, Pair collectivite, Pair budget, Pair key1, Pair key2, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeSpecialKey2(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
- logger.debug("deleting " + dm.getId() + "/" + collectivite.libelle + "/" + budget.libelle + "/" + key1.key + "/" + key2.key);
+ OracleDataLayer.logger.debug("deleting " + dm.getId() + "/" + collectivite.libelle + "/" + budget.libelle + "/" + key1.key + "/" + key2.key);
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=? AND KEY2=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.setString(3, key1.key);
ps.setString(4, key2.key);
- ResultSet rs = ps.executeQuery();
- TreeSet<String> al = new TreeSet<String>();
+ final ResultSet rs = ps.executeQuery();
+ final TreeSet<String> al = new TreeSet<String>();
while (rs.next()) {
al.add(rs.getString(1));
}
- for (String docName : al) {
- removeDocument(dm, budget, collectivite, docName, user);
+ for (final String docName : al) {
+ this.removeDocument(dm, budget, collectivite, docName, user);
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean removeSpecialKey3(DocumentModel dm, Pair collectivite, Pair budget, Pair key1, Pair key2, Pair key3, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean removeSpecialKey3(final DocumentModel dm, final Pair collectivite, final Pair budget, final Pair key1, final Pair key2, final Pair key3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des données");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à supprimer des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName())
- .append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=? AND KEY2=? AND KEY3=?");
+ final StringBuilder sb = new StringBuilder();
+ sb.append("SELECT " + pc.getInitialDocNameColname() + " FROM ").append(pc.getSpecialKeyTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND KEY1=? AND KEY2=? AND KEY3=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, budget.key);
ps.setString(3, key1.key);
ps.setString(4, key2.key);
ps.setString(5, key3.key);
- ResultSet rs = ps.executeQuery();
- TreeSet<String> al = new TreeSet<String>();
+ final ResultSet rs = ps.executeQuery();
+ final TreeSet<String> al = new TreeSet<String>();
while (rs.next()) {
al.add(rs.getString(1));
}
- for (String docName : al) {
- removeDocument(dm, budget, collectivite, docName, user);
+ for (final String docName : al) {
+ this.removeDocument(dm, budget, collectivite, docName, user);
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public DataResultSet search(ElementModel elementModel, Pair collectivite, Pair budget, String xPath, ListeResultatModel lrm, Vector<CritereModel> models, XemeliosUser user) throws DataConfigurationException, DataAccessException,
- UnauthorizedException {
+ public DataResultSet search(final ElementModel elementModel, final Pair collectivite, final Pair budget, final String xPath, final ListeResultatModel lrm, final Vector<CritereModel> models, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + elementModel.getTitre());
}
if (!user.hasCollectivite(collectivite.key, elementModel.getParent().getParent())) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + elementModel.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + elementModel.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- String sql = transformXPathToSql(elementModel, collectivite, budget, xPath, models, user);
- logger.debug(sql);
+ final String sql = this.transformXPathToSql(elementModel, collectivite, budget, xPath, models, user);
+ OracleDataLayer.logger.debug(sql);
DataResultSet rs = null;
try {
rs = new OracleDataResultSet(elementModel, collectivite, budget, xPath, sql, lrm, this, user);
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataConfigurationException(sqlEx);
}
return rs;
}
@Override
- public Pair[] getOperators(String datatype) {
+ public Pair[] getOperators(final String datatype) {
if ("string".equals(datatype)) {
- return new Pair[] { new Pair("starts-with", "commence par"), new Pair("contains", "contient"), new Pair("xem:does-not-contain", "ne contient pas"), new Pair("xem:ends-with", "fini par"), new Pair("xem:StringEquals", "égal à "),
- new Pair("xem:StringDiffers", "diffère de"), new Pair("xem:StringIsNotNull", "n'est pas nul") };
+ return new Pair[] { new Pair("starts-with", "commence par"), new Pair("contains", "contient"), new Pair("xem:does-not-contain", "ne contient pas"), new Pair("xem:ends-with", "fini par"), new Pair("xem:StringEquals", "égal à "), new Pair("xem:StringDiffers", "diffère de"),
+ new Pair("xem:StringIsNotNull", "n'est pas nul") };
} else if ("numeric".equals(datatype)) {
return new Pair[] { new Pair("=", "="), new Pair(">=", ">="), new Pair(">", ">"), new Pair("<", "<"), new Pair("<=", "<="), new Pair("!=", "!=") };
} else if ("date".equals(datatype)) {
@Override
@Deprecated
- public String getDocumentAsString(EtatModel etatModel, Pair collectivite, Pair budget, String docId, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public String getDocumentAsString(final EtatModel etatModel, final Pair collectivite, final Pair budget, final String docId, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
- public Document getDocumentAsDom(EtatModel etatModel, Pair collectivite, Pair budget, String docId, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Document getDocumentAsDom(final EtatModel etatModel, final Pair collectivite, final Pair budget, final String docId, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre());
}
if (!user.hasCollectivite(collectivite.key, etatModel.getParent())) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- DocumentModel dm = etatModel.getParent();
+ final DocumentModel dm = etatModel.getParent();
Document ret = null;
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(etatModel.getParent().getId());
- TEtat sec = pc.getEtat(etatModel.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(etatModel.getParent().getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DOC FROM ").append(sec.getDocumentTable().getBaseName()).append(" WHERE " + pc.getBudgetCodeColname() + "=? AND " + pc.getCollectiviteCodeColname() + "=? AND DOC_ID=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, budget.key);
ps.setString(2, collectivite.key);
ps.setString(3, docId);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
- ret = parseDOMFromInputStream(domFactory, docIn);
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
+ ret = this.parseDOMFromInputStream(this.domFactory, docIn);
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
- } catch (ParserConfigurationException pcEx) {
+ } catch (final ParserConfigurationException pcEx) {
throw new DataConfigurationException(pcEx);
- } catch (SAXException saxEx) {
+ } catch (final SAXException saxEx) {
throw new DataAccessException(saxEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public DocumentInfos getDocumentInfos(EtatModel etatModel, Pair collectivite, Pair budget, String docId, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public DocumentInfos getDocumentInfos(final EtatModel etatModel, final Pair collectivite, final Pair budget, final String docId, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (user != null) {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre());
}
if (!user.hasCollectivite(collectivite.key, etatModel.getParent())) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + etatModel.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
}
- DocumentModel dm = etatModel.getParent();
+ final DocumentModel dm = etatModel.getParent();
Document ret = null;
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(etatModel.getParent().getId());
- TEtat sec = pc.getEtat(etatModel.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(etatModel.getParent().getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT DOC FROM ").append(sec.getDocumentTable().getBaseName()).append(" WHERE " + pc.getBudgetCodeColname() + "=? AND " + pc.getCollectiviteCodeColname() + "=? AND DOC_ID=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, budget.key);
ps.setString(2, collectivite.key);
ps.setString(3, docId);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- ret = parseDOMFromInputStream(domFactory, docIn);
+ ret = this.parseDOMFromInputStream(this.domFactory, docIn);
} finally {
docIn.close();
}
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
- } catch (IOException ioEx) {
+ } catch (final IOException ioEx) {
throw new DataAccessException(ioEx);
- } catch (ParserConfigurationException pcEx) {
+ } catch (final ParserConfigurationException pcEx) {
throw new DataConfigurationException(pcEx);
- } catch (SAXException saxEx) {
- logger.debug("Problème avec le document : " + docId);
+ } catch (final SAXException saxEx) {
+ OracleDataLayer.logger.debug("Problème avec le document : " + docId);
throw new DataAccessException(saxEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
}
if (ret == null) {
- logger.info("ret is null !");
+ OracleDataLayer.logger.info("ret is null !");
}
return new DocumentInfos(docId, ret);
}
@Override
- public void importPj(PJRef pj, String archiveName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- if (!user.hasRole(XemeliosUser.ROLE_IMPORT))
- throw new UnauthorizedException(String.format(getMessages().getString(NOT_ALLOWED_ROLE), getMessages().getString(ROLE_IMPORT)));
- if (!user.hasCollectivite(pj.getCollectivite(), null))
- throw new UnauthorizedException(String.format(getMessages().getString(NOT_ALLOWED_COLLECTIVITE), pj.getCollectivite()));
+ public void importPj(final PJRef pj, final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
+ throw new UnauthorizedException(String.format(this.getMessages().getString(MessageEntries.NOT_ALLOWED_ROLE), this.getMessages().getString(MessageEntries.ROLE_IMPORT)));
+ }
+ if (!user.hasCollectivite(pj.getCollectivite(), null)) {
+ throw new UnauthorizedException(String.format(this.getMessages().getString(MessageEntries.NOT_ALLOWED_COLLECTIVITE), pj.getCollectivite()));
+ }
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- String idUnique = pj.getPjName() != null ? pj.getPjName() : pj.getFileName();
+ final String idUnique = pj.getPjName() != null ? pj.getPjName() : pj.getFileName();
ps = con.prepareStatement("SELECT 1 FROM ATTACHMENTS WHERE COLLECTIVITE=? AND ID_UNIQUE=?");
ps.setString(1, pj.getCollectivite());
ps.setString(2, idUnique);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
// il faut supprimer la référence
rs.close();
ps.setNull(5, Types.VARCHAR);
}
ps.executeUpdate();
- if (pj.getPath() == null && pj.getUncompressedSize() > 0 && pj.getData() != null && pj.getData().length > 0) {
+ if ((pj.getPath() == null) && (pj.getUncompressedSize() > 0) && (pj.getData() != null) && (pj.getData().length > 0)) {
// il faut aller stocker la PJ
- String basePath = getParameterValue(PJ_NO_ARCH_BASE_PATH);
- if (basePath == null)
- throw new DataConfigurationException("Paramètre " + PJ_NO_ARCH_BASE_PATH + " non définit");
- File baseDir = new File(basePath);
- if (!baseDir.exists())
+ final String basePath = this.getParameterValue(OracleDataLayer.PJ_NO_ARCH_BASE_PATH);
+ if (basePath == null) {
+ throw new DataConfigurationException("Paramètre " + OracleDataLayer.PJ_NO_ARCH_BASE_PATH + " non définit");
+ }
+ final File baseDir = new File(basePath);
+ if (!baseDir.exists()) {
baseDir.mkdirs();
- File collectiviteDir = new File(baseDir, pj.getCollectivite());
+ }
+ final File collectiviteDir = new File(baseDir, pj.getCollectivite());
- String hash = Integer.toHexString(archiveLocator.getCollectiviteHash(idUnique)).toUpperCase();
- File pjDir = new File(collectiviteDir, hash);
+ final String hash = Integer.toHexString(this.archiveLocator.getCollectiviteHash(idUnique)).toUpperCase();
+ final File pjDir = new File(collectiviteDir, hash);
pjDir.mkdirs();
- File pjFile = new File(pjDir, idUnique);
- FileOutputStream fos = new FileOutputStream(pjFile);
+ final File pjFile = new File(pjDir, idUnique);
+ final FileOutputStream fos = new FileOutputStream(pjFile);
fos.write(pj.getData());
fos.flush();
fos.close();
}
- } catch (Exception ex) {
- logger.error("impossible d'enregistrer la PJ", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("impossible d'enregistrer la PJ", ex);
} finally {
- if (con != null)
+ if (con != null) {
PoolManager.getInstance().releaseConnection(con);
+ }
}
}
@Override
- public PJRef getPj(Pair collectivite, String pjName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- Connection con = null;
- PJRef ret = null;
+ public PJRef getPj(final Pair collectivite, final String pjName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ PJRef result = null;
+
+ final Connection con = PoolManager.getInstance().getConnection();
try {
- con = PoolManager.getInstance().getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT IN_ARCHIVE, ARCHIVE_NAME, PATH FROM ATTACHMENTS WHERE COLLECTIVITE=? AND ID_UNIQUE=?");
+ final PreparedStatement ps = con.prepareStatement("SELECT IN_ARCHIVE, ARCHIVE_NAME, PATH FROM ATTACHMENTS WHERE COLLECTIVITE=? AND ID_UNIQUE=?");
ps.setString(1, collectivite.key);
ps.setString(2, pjName);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
+
if (rs.next()) {
- ret = new PJRef();
- boolean inArchive = rs.getInt(1) == 1;
- String archiveName = rs.getString(2);
- String path = rs.getString(3);
+ final boolean inArchive = rs.getInt(1) == 1;
+ final String archiveName = rs.getString(2);
+ final String path = rs.getString(3);
+
if (inArchive) {
+ final File mainArchiveFile = this.archiveLocator.getArchiveLocation(archiveName);
+ final File[] allArchives = mainArchiveFile.getParentFile().listFiles((FileFilter) new WildcardFileFilter("*.xar"));
- File archiveFile = archiveLocator.getArchiveLocation(archiveName);
+ // recherche de la PJ dans les archives (multivolume)
+ boolean pjFound = false;
+ for (int i = 0; (i < allArchives.length) && !pjFound; i++) {
+ final ZipFile zip = new ZipFile(allArchives[i]);
+ try {
+ final ZipEntry ze = zip.getEntry(path);
+
+ // PJ trouvée ?
+ if (ze != null) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final InputStream is = zip.getInputStream(ze);
+ try {
+ IOUtils.copy(is, baos);
+ } finally {
+ is.close();
+ }
- // dégueux : patch pour pb affichage des PJ
- if (!archiveFile.exists()) {
- archiveName = archiveName.substring(0, archiveName.lastIndexOf(".")) + "_1.xar";
- archiveFile = new File(archiveFile.getParent(), archiveName);
- }
+ result = new PJRef();
+ result.setData(baos.toByteArray());
+ result.setCollectivite(collectivite.key);
+ result.setFileName(path.substring(path.lastIndexOf('/') + 1));
- if (archiveFile.exists()) {
- ZipFile zip = new ZipFile(archiveFile);
- ZipEntry ze = zip.getEntry(path);
- InputStream is = zip.getInputStream(ze);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int read = is.read(buffer);
- while (read > 0) {
- baos.write(buffer, 0, read);
- read = is.read(buffer);
+ pjFound = true;
+ }
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e, e);
+ } finally {
+ zip.close();
}
- is.close();
- zip.close();
- baos.flush();
- baos.close();
- ret.setData(baos.toByteArray());
- ret.setCollectivite(collectivite.key);
- ret.setFileName(path.substring(path.lastIndexOf('/') + 1));
- } else {
- ret = null;
- logger.warn("expecting " + archiveFile.toURI().toURL().toExternalForm() + " no found");
}
} else {
- String basePath = getParameterValue(PJ_NO_ARCH_BASE_PATH);
- if (basePath == null)
- throw new DataConfigurationException("Paramètre " + PJ_NO_ARCH_BASE_PATH + " non définit");
- File baseDir = new File(basePath);
- File collectiviteDir = new File(baseDir, collectivite.key);
- String hash = Integer.toHexString(archiveLocator.getCollectiviteHash(pjName)).toUpperCase();
- File pjDir = new File(collectiviteDir, hash);
- File pjFile = new File(pjDir, pjName);
- if (!pjFile.exists()) {
- ret = null;
- } else {
- FileInputStream fis = new FileInputStream(pjFile);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- byte[] buffer = new byte[1024];
- int read = fis.read(buffer);
- while (read > 0) {
- baos.write(buffer, 0, read);
- read = fis.read(buffer);
+ final String basePath = this.getParameterValue(OracleDataLayer.PJ_NO_ARCH_BASE_PATH);
+ if (basePath == null) {
+ throw new DataConfigurationException("Paramètre " + OracleDataLayer.PJ_NO_ARCH_BASE_PATH + " non définit");
+ }
+
+ final File baseDir = new File(basePath);
+ final File collectiviteDir = new File(baseDir, collectivite.key);
+ final String hash = Integer.toHexString(this.archiveLocator.getCollectiviteHash(pjName)).toUpperCase();
+ final File pjDir = new File(collectiviteDir, hash);
+ final File pjFile = new File(pjDir, pjName);
+
+ if (pjFile.exists()) {
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final FileInputStream is = new FileInputStream(pjFile);
+
+ try {
+ IOUtils.copy(is, baos);
+ } finally {
+ is.close();
}
- fis.close();
- baos.flush();
- baos.close();
- ret.setData(baos.toByteArray());
- ret.setCollectivite(collectivite.key);
- ret.setFileName(pjFile.getName());
+
+ result = new PJRef();
+ result.setData(baos.toByteArray());
+ result.setCollectivite(collectivite.key);
+ result.setFileName(pjFile.getName());
}
}
}
- } catch (Exception ex) {
- logger.error("getPj(Pair,String,XemeliosUser)", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("getPj(Pair,String,XemeliosUser)", ex);
} finally {
- if (con != null)
- PoolManager.getInstance().releaseConnection(con);
+ PoolManager.getInstance().releaseConnection(con);
}
- return ret;
+
+ return result;
}
@Override
- public PJRef getPjByUniqueId(Pair collectivite, String id, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- return getPj(collectivite, id, user);
+ public PJRef getPjByUniqueId(final Pair collectivite, final String id, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ return this.getPj(collectivite, id, user);
}
@Override
- public boolean isPjAvailable(Pair collectivite, String id, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean isPjAvailable(final Pair collectivite, final String id, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT 1 FROM ATTACHMENTS WHERE COLLECTIVITE=? AND ID_UNIQUE=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
ps.setString(2, id);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = true;
}
rs.close();
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
@Override
public String getLastWarnings() {
- return warnings.get(Thread.currentThread()).toString();
+ return this.warnings.get(Thread.currentThread()).toString();
}
@Override
- public ArrayList<String> getDocumentListFromSpecialKeys(ElementModel em, String collectivite, String budget, String sp1, String sp2, String sp3, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public ArrayList<String> getDocumentListFromSpecialKeys(final ElementModel em, final String collectivite, final String budget, final String sp1, final String sp2, final String sp3, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
if (!user.hasCollectivite(collectivite, em.getParent().getParent())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des données pour cette collectivité");
}
- ArrayList<String> ret = new ArrayList<String>();
- StringBuffer sb = new StringBuffer();
- EtatModel etatModel = em.getParent();
- TDocument pc = getPersistenceConfig(etatModel.getParent(), user).getLayer(getLayerName()).getDocument(etatModel.getParent().getId());
- TEtat sec = pc.getEtat(etatModel.getId());
+ final ArrayList<String> ret = new ArrayList<String>();
+ final StringBuffer sb = new StringBuffer();
+ final EtatModel etatModel = em.getParent();
+ final TDocument pc = this.getPersistenceConfig(etatModel.getParent(), user).getLayer(this.getLayerName()).getDocument(etatModel.getParent().getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
sb.append("SELECT DOC_ID FROM ").append(sec.getMaintable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND " + pc.getBudgetCodeColname() + "=? ");
- DocumentModel dm = etatModel.getParent();
- Vector<SpecialKeyModel> specialKeys = dm.getSpecialKeys();
+ final DocumentModel dm = etatModel.getParent();
+ final Vector<SpecialKeyModel> specialKeys = dm.getSpecialKeys();
if (sp1 != null) {
// search SPK1 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 1) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
if (si.getTableId().equals(sec.getMaintable().getId())) {
// ok, it is the same table
sb.append("AND ").append(si.getColumn()).append("=? ");
if (sp2 != null) {
// search SPK1 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 2) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
if (si.getTableId().equals(sec.getMaintable().getId())) {
// ok, it is the same table
sb.append("AND ").append(si.getColumn()).append("=? ");
if (sp3 != null) {
// search SPK3 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 3) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
if (si.getTableId().equals(sec.getMaintable().getId())) {
// ok, it is the same table
sb.append("AND ").append(si.getColumn()).append("=? ");
throw new DataConfigurationException("no special key in pos 3 defined for " + dm.getId());
}
}
- logger.debug(sb.toString());
+ OracleDataLayer.logger.debug(sb.toString());
// well, now sql is complete
Connection con = null;
PreparedStatement ps = null;
con = PoolManager.getInstance().getConnection();
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite);
- logger.debug("1->" + collectivite);
+ OracleDataLayer.logger.debug("1->" + collectivite);
ps.setString(2, budget);
- logger.debug("2->" + budget);
+ OracleDataLayer.logger.debug("2->" + budget);
if (sp1 != null) {
ps.setString(3, sp1);
- logger.debug("3->" + sp1);
+ OracleDataLayer.logger.debug("3->" + sp1);
}
if (sp2 != null) {
ps.setString(4, sp2);
while (rs.next()) {
ret.add(rs.getString(1));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (rs != null) {
try {
rs.close();
- } catch (Throwable t) {
- logger.info("rs closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("rs closed !", t);
}
}
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public ArrayList<String> getDocumentListFromXPath(ElementModel em, String collectivite, String budget, String sp1, String sp2, String sp3, String xpath, XemeliosUser user) throws DataConfigurationException, DataAccessException,
+ public ArrayList<String> getDocumentListFromXPath(final ElementModel em, final String collectivite, final String budget, final String sp1, final String sp2, final String sp3, final String xpath, final XemeliosUser user) throws DataConfigurationException, DataAccessException,
UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
if (!user.hasCollectivite(collectivite, em.getParent().getParent())) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des données pour cette collectivité");
}
- ArrayList<String> ret = new ArrayList<String>();
- StringBuffer selectClause = new StringBuffer();
- StringBuffer fromClause = new StringBuffer();
- StringBuffer whereClause = new StringBuffer();
- ArrayList<String> addedTableNames = new ArrayList<String>();
- EtatModel etatModel = em.getParent();
- TDocument pc = getPersistenceConfig(etatModel.getParent(), user).getLayer(getLayerName()).getDocument(etatModel.getParent().getId());
- TEtat sec = pc.getEtat(etatModel.getId());
+ final ArrayList<String> ret = new ArrayList<String>();
+ final StringBuffer selectClause = new StringBuffer();
+ final StringBuffer fromClause = new StringBuffer();
+ final StringBuffer whereClause = new StringBuffer();
+ final ArrayList<String> addedTableNames = new ArrayList<String>();
+ final EtatModel etatModel = em.getParent();
+ final TDocument pc = this.getPersistenceConfig(etatModel.getParent(), user).getLayer(this.getLayerName()).getDocument(etatModel.getParent().getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
selectClause.append("SELECT DISTINCT(").append(sec.getMaintable().getBaseName()).append(".DOC_ID) ");
fromClause.append("FROM ").append(sec.getMaintable().getBaseName()).append(" ");
addedTableNames.add(sec.getMaintable().getId());
whereClause.append(" WHERE ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=? AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=? ");
- DocumentModel dm = etatModel.getParent();
- Vector<SpecialKeyModel> specialKeys = dm.getSpecialKeys();
+ final DocumentModel dm = etatModel.getParent();
+ final Vector<SpecialKeyModel> specialKeys = dm.getSpecialKeys();
if (sp1 != null) {
// search SPK1 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 1) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
- String tName = sec.getIndexTable(si.getTableId()).getBaseName();
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String tName = sec.getIndexTable(si.getTableId()).getBaseName();
whereClause.append("AND ").append(tName).append(".").append(si.getColumn()).append("=? ");
if (!addedTableNames.contains(si.getTableId())) {
- fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName())
- .append("." + pc.getCollectiviteCodeColname() + "=").append(tName).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=")
- .append(tName).append("." + pc.getBudgetCodeColname() + "");
+ fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=").append(tName)
+ .append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=").append(tName).append("." + pc.getBudgetCodeColname() + "");
addedTableNames.add(si.getTableId());
}
} else {
if (sp2 != null) {
// search SPK1 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 2) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
- String tName = sec.getIndexTable(si.getTableId()).getBaseName();
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String tName = sec.getIndexTable(si.getTableId()).getBaseName();
whereClause.append("AND ").append(tName).append(".").append(si.getColumn()).append("=? ");
if (!addedTableNames.contains(si.getTableId())) {
- fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName())
- .append("." + pc.getCollectiviteCodeColname() + "=").append(tName).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=")
- .append(tName).append("." + pc.getBudgetCodeColname() + "");
+ fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=").append(tName)
+ .append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=").append(tName).append("." + pc.getBudgetCodeColname() + "");
addedTableNames.add(si.getTableId());
}
} else {
if (sp3 != null) {
// search SPK3 XPath
SpecialKeyModel skm = null;
- for (SpecialKeyModel sk : specialKeys) {
+ for (final SpecialKeyModel sk : specialKeys) {
if (sk.getPos() == 3) {
skm = sk;
}
}
if (skm != null) {
- String path = skm.getPath();
- TSqlIndex si = sec.getSqlIndexByPath(path);
- String tName = sec.getIndexTable(si.getTableId()).getBaseName();
+ final String path = skm.getPath();
+ final TSqlIndex si = sec.getSqlIndexByPath(path);
+ final String tName = sec.getIndexTable(si.getTableId()).getBaseName();
whereClause.append("AND ").append(tName).append(".").append(si.getColumn()).append("=? ");
if (!addedTableNames.contains(si.getTableId())) {
- fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName())
- .append("." + pc.getCollectiviteCodeColname() + "=").append(tName).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=")
- .append(tName).append("." + pc.getBudgetCodeColname() + "");
+ fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=").append(tName)
+ .append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=").append(tName).append("." + pc.getBudgetCodeColname() + "");
addedTableNames.add(si.getTableId());
}
} else {
* sont indexes, alors on pourra ajouter des clauses where dans le sql. Cette syntaxe devrait etre suffisante pour gérer la navigation dans le
* compte de gestion. C'est du bricolage, mais je n'ai pas d'autre solution pour le moment
*/
- logger.debug("xpath is " + xpath);
+ OracleDataLayer.logger.debug("xpath is " + xpath);
if (xpath.startsWith(em.getPath().getPath())) {
final String shortPath = xpath.substring(em.getPath().getPath().length());
if (!shortPath.startsWith("[")) {
throw new DataConfigurationException("XPath too complicated. This implementation can only deal with XPath formed by <path-to-element>[cond on sub-element][cond on sub element]...");
}
// decoupage par groupe de [...]
- String[] conds = splitConditions(shortPath);
+ final String[] conds = OracleDataLayer.splitConditions(shortPath);
for (String s : conds) {
- logger.debug(s);
+ OracleDataLayer.logger.debug(s);
// pour le moment, on cherche les opérateurs <= >= = < >
s = s.substring(1, s.length() - 1);
String op = null;
}
}
}
- String left = s.substring(0, pos);
- String right = s.substring(pos + op.length());
- String indexedPath = em.getPath().getPath() + "/" + left;
- logger.debug(indexedPath + " " + op + " " + right);
+ final String left = s.substring(0, pos);
+ final String right = s.substring(pos + op.length());
+ final String indexedPath = em.getPath().getPath() + "/" + left;
+ OracleDataLayer.logger.debug(indexedPath + " " + op + " " + right);
//
- TSqlIndex si = sec.getSqlIndexByPath(indexedPath);
+ final TSqlIndex si = sec.getSqlIndexByPath(indexedPath);
if (si != null) {
- String tName = sec.getIndexTable(si.getTableId()).getBaseName();
+ final String tName = sec.getIndexTable(si.getTableId()).getBaseName();
String value = null;
if ("string".equals(si.getDatatype())) {
value = MySqlDataLayer.sqlEscapeString(si.getFormattedStringValue(right));
}
whereClause.append("AND ").append(tName).append(".").append(si.getColumn()).append(op).append(value).append(" ");
if (!addedTableNames.contains(si.getTableId())) {
- fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName())
- .append("." + pc.getCollectiviteCodeColname() + "=").append(tName).append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=")
- .append(tName).append("." + pc.getBudgetCodeColname() + "");
+ fromClause.append(" LEFT OUTER JOIN ").append(tName).append(" ON ").append(sec.getMaintable().getBaseName()).append(".DOC_ID=").append(tName).append(".DOC_ID AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getCollectiviteCodeColname() + "=").append(tName)
+ .append("." + pc.getCollectiviteCodeColname() + " AND ").append(sec.getMaintable().getBaseName()).append("." + pc.getBudgetCodeColname() + "=").append(tName).append("." + pc.getBudgetCodeColname() + "");
addedTableNames.add(si.getTableId());
}
} else {
// donc on fait ce
// gros patch tout pourri !
sql = sql.replaceAll("= *''", " IS NULL");
- logger.debug(sql);
+ OracleDataLayer.logger.debug(sql);
// well, now sql is complete
Connection con = null;
PreparedStatement ps = null;
con = PoolManager.getInstance().getConnection();
ps = con.prepareStatement(sql);
ps.setString(1, collectivite);
- logger.debug("1(coll)->" + collectivite);
+ OracleDataLayer.logger.debug("1(coll)->" + collectivite);
ps.setString(2, budget);
- logger.debug("2(budg)->" + budget);
+ OracleDataLayer.logger.debug("2(budg)->" + budget);
if (sp1 != null) {
ps.setString(3, sp1);
- logger.debug("3(sp1 )->" + sp1);
+ OracleDataLayer.logger.debug("3(sp1 )->" + sp1);
}
if (sp2 != null) {
ps.setString(4, sp2);
- logger.debug("4(sp2 )->" + sp2);
+ OracleDataLayer.logger.debug("4(sp2 )->" + sp2);
}
if (sp3 != null) {
ps.setString(5, sp3);
- logger.debug("5(sp3 )->" + sp3);
+ OracleDataLayer.logger.debug("5(sp3 )->" + sp3);
}
rs = ps.executeQuery();
while (rs.next()) {
ret.add(rs.getString(1));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (rs != null) {
try {
rs.close();
- } catch (Throwable t) {
- logger.info("rs closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("rs closed !", t);
}
}
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public nu.xom.Document getManifesteFromArchive(String archiveName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public nu.xom.Document getManifesteFromArchive(final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
DocumentModel dm = null;
try {
dm = Loader.getDocumentsInfos(null).getDocumentById("manifeste2");
- } catch (Throwable ignore) {
+ } catch (final Throwable ignore) {
}
- String etatId = "fakes";
+ final String etatId = "fakes";
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
nu.xom.Document manifeste = null;
try {
con = PoolManager.getInstance().getConnection();
- ensureTablesExists(pc, pc.getEtat("fakes"), con);
- StringBuilder sb = new StringBuilder();
+ this.ensureTablesExists(pc, pc.getEtat("fakes"), con);
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT docs.DOC FROM " + pc.getEtat(etatId).getIndexTable("MANIFESTE_VOLUME_IX").getBaseName() + " ix");
sb.append(" INNER JOIN " + pc.getEtat(etatId).getDocumentTable().getBaseName() + " docs ON docs." + pc.getArchiveNameColname() + "=ix." + pc.getArchiveNameColname());
sb.append(" WHERE docs." + pc.getArchiveNameColname() + " = ?");// AND ARCHIVE_PRESENT='Oui'
- logger.debug(sb.toString());
+ OracleDataLayer.logger.debug(sb.toString());
ps = con.prepareStatement(sb.toString());
ps.setString(1, archiveName);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
manifeste = new nu.xom.Builder().build(docIn);
} finally {
}
if (rs.next()) {
- logger.warn("Plusieurs manifestes trouvés !!!");
+ OracleDataLayer.logger.warn("Plusieurs manifestes trouvés !!!");
}
- } catch (Throwable t) {
- logger.error("getManifesteFromArchive(" + archiveName + ")", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.error("getManifesteFromArchive(" + archiveName + ")", t);
throw new DataConfigurationException("invalid code !", t);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public boolean updateManifeste(String archiveName, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public boolean updateManifeste(final String archiveName, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
boolean retour = true;
if (!user.hasRole(XemeliosUser.ROLE_CLEAN)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des mises à jour de données");
}
- Connection con = PoolManager.getInstance().getConnection();
+ final Connection con = PoolManager.getInstance().getConnection();
try {
ResultSet rs = null;
- TDocument tDoc = getPersistenceConfig(Loader.getConfigurationFromLoadedFiles().getDocumentById("manifeste"), user).getLayer(getLayerName()).getDocument("manifeste");
+ final TDocument tDoc = this.getPersistenceConfig(Loader.getConfigurationFromLoadedFiles().getDocumentById("manifeste"), user).getLayer(this.getLayerName()).getDocument("manifeste");
// vérification de l'existence de la table "manifest"
- PreparedStatement tableExists = con.prepareStatement("SELECT * FROM " + tDoc.getEtat("Referentiel").getMaintable().getBaseName());
+ final PreparedStatement tableExists = con.prepareStatement("SELECT * FROM " + tDoc.getEtat("Referentiel").getMaintable().getBaseName());
try {
rs = tableExists.executeQuery();
- } catch (Exception e) {
- logger.warn("Les tables de manifestes n'existent pas ! " + e.getMessage());
+ } catch (final Exception e) {
+ OracleDataLayer.logger.warn("Les tables de manifestes n'existent pas ! " + e.getMessage());
throw new DataConfigurationException("Les tables de manifestes n'existent pas !");
} finally {
tableExists.close();
}
- if (rs != null && rs.next()) {
+ if ((rs != null) && rs.next()) {
// Je sais pas pourquoi on fais ça????
- PreparedStatement updPresenceArchive = con.prepareStatement("UPDATE " + tDoc.getEtat("Referentiel").getMaintable().getBaseName() + " SET ARCHIVE_PRESENT=? WHERE ARCHIVE_NAME=?");
+ final PreparedStatement updPresenceArchive = con.prepareStatement("UPDATE " + tDoc.getEtat("Referentiel").getMaintable().getBaseName() + " SET ARCHIVE_PRESENT=? WHERE ARCHIVE_NAME=?");
try {
updPresenceArchive.setString(1, "Non");
updPresenceArchive.setString(2, archiveName);
}
// On récupère l'ancien manifeste
- PreparedStatement ps = con.prepareStatement("SELECT DOC FROM " + tDoc.getEtat("manifeste").getDocumentTable().getBaseName() + " WHERE ARCHIVE_NAME=?");
+ final PreparedStatement ps = con.prepareStatement("SELECT DOC FROM " + tDoc.getEtat("manifeste").getDocumentTable().getBaseName() + " WHERE ARCHIVE_NAME=?");
try {
ps.setString(1, archiveName);
rs = ps.executeQuery();
if (rs.next()) {
Document doc;
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- DocumentBuilder builder = domFactory.newDocumentBuilder();
+ final DocumentBuilder builder = this.domFactory.newDocumentBuilder();
doc = builder.parse(new InputSource(docIn));
} finally {
docIn.close();
}
// transformation xsl du manifest
- Transformer trans = FactoryProvider.getTransformerFactory().newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream("fr/gouv/finances/dgfip/xemelios/manifeste/manifeste-patcher.xsl")));
- ByteArrayOutputStream newManifestBaos = new ByteArrayOutputStream();
+ final Transformer trans = FactoryProvider.getTransformerFactory().newTransformer(new StreamSource(this.getClass().getClassLoader().getResourceAsStream("fr/gouv/finances/dgfip/xemelios/manifeste/manifeste-patcher.xsl")));
+ final ByteArrayOutputStream newManifestBaos = new ByteArrayOutputStream();
trans.transform(new DOMSource(doc), new StreamResult(newManifestBaos));
// Mise à jour du manifest
- PreparedStatement updManifpstmt = con.prepareStatement("UPDATE " + tDoc.getEtat("manifeste").getDocumentTable().getBaseName() + " SET DOC=? WHERE ARCHIVE_NAME=?");
+ final PreparedStatement updManifpstmt = con.prepareStatement("UPDATE " + tDoc.getEtat("manifeste").getDocumentTable().getBaseName() + " SET DOC=? WHERE ARCHIVE_NAME=?");
try {
updManifpstmt.setString(2, archiveName);
// gzip du nouveau manifest
- ByteArrayOutputStream gzipBaos = new ByteArrayOutputStream();
- GZIPOutputStream gzip = new GZIPOutputStream(gzipBaos);
+ final ByteArrayOutputStream gzipBaos = new ByteArrayOutputStream();
+ final GZIPOutputStream gzip = new GZIPOutputStream(gzipBaos);
try {
gzip.write(newManifestBaos.toByteArray());
gzip.flush();
ps.close();
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new DataConfigurationException("Problème lors de la mise à jour des données de la tracabilité !", e);
} finally {
PoolManager.getInstance().releaseConnection(con);
@Override
public SimpleDateFormat getDateFormatter() {
- return oracleDateFormat;
+ return OracleDataLayer.oracleDateFormat;
}
@Override
- public Pair[] getAggregateOperators(String datatype) {
- ArrayList<Pair> result = new ArrayList<Pair>();
- logger.debug("Requested aggregate operators for data type " + datatype);
+ public Pair[] getAggregateOperators(final String datatype) {
+ final ArrayList<Pair> result = new ArrayList<Pair>();
+ OracleDataLayer.logger.debug("Requested aggregate operators for data type " + datatype);
if (datatype.equals(ChampModel.DATATYPE_INTEGER) || datatype.equals(ChampModel.DATATYPE_DECIMAL) || datatype.equals(ChampModel.DATATYPE_AMOUNT)) {
result.add(new Pair("AVG", "Moyenne"));
result.add(new Pair("SUM", "Somme"));
result.add(new Pair("SEC_TO_TIME(AVG(TIME_TO_SEC", "Moyenne"));
}
- Pair[] aRet = new Pair[result.size()];
+ final Pair[] aRet = new Pair[result.size()];
result.toArray(aRet);
return aRet;
}
@Override
- public String calculateAggregate(DocumentModel dm, EtatModel em, String columnXPath, String operator, ChampModel cm, DataResultSet rs, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public String calculateAggregate(final DocumentModel dm, final EtatModel em, String columnXPath, final String operator, final ChampModel cm, final DataResultSet rs, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre());
}
if (!user.hasCollectivite(rs.getCollectivite().key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + rs.getCollectivite().libelle != null ? "(" + rs.getCollectivite().libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + rs.getCollectivite().libelle) != null ? "(" + rs.getCollectivite().libelle + ")" : "");
}
- TPersistenceConfig pers = this.getPersistenceConfig(dm, user);
- TLayer layer = pers.getLayer(this.getLayerName());
- TDocument tdoc = layer.getDocument(dm.getId());
- TEtat tet = tdoc.getEtat(em.getId());
+ final TPersistenceConfig pers = this.getPersistenceConfig(dm, user);
+ final TLayer layer = pers.getLayer(this.getLayerName());
+ final TDocument tdoc = layer.getDocument(dm.getId());
+ final TEtat tet = tdoc.getEtat(em.getId());
// parfois, il y a des informations de position dans les xpath
// d'affichage de colonne, il faut les supprimer
columnXPath = columnXPath.replaceAll("\\[[0-9]\\]", "");
- logger.debug(columnXPath);
- TSqlIndex tsqlIndex = tet.getSqlIndexByPath(columnXPath);
+ OracleDataLayer.logger.debug(columnXPath);
+ final TSqlIndex tsqlIndex = tet.getSqlIndexByPath(columnXPath);
if (tsqlIndex == null) {
throw new DataConfigurationException("Pas d'index sur " + columnXPath);
}
- String columnName = tsqlIndex.getColumn();
- String tableName = tet.getIndexTable(tsqlIndex.getTableId()).getBaseName();
+ final String columnName = tsqlIndex.getColumn();
+ final String tableName = tet.getIndexTable(tsqlIndex.getTableId()).getBaseName();
- OracleDataResultSet oraRs = (OracleDataResultSet) rs;
+ final OracleDataResultSet oraRs = (OracleDataResultSet) rs;
return oraRs.calculateAggregate(tableName + "." + columnName, tableName, operator, cm);
}
@Override
- public void insertConfigExport(ConfigModel cm, XemeliosUser user) {
+ public void insertConfigExport(final ConfigModel cm, final XemeliosUser user) {
Connection con = null;
Statement st = null;
PreparedStatement ps = null;
st = con.createStatement();
rs = st.executeQuery("SELECT SQ_CFG_EXPORTS.nextval from dual");
rs.next();
- long id = rs.getLong(1);
+ final long id = rs.getLong(1);
ps = con.prepareStatement("INSERT INTO CONFIGS_EXPORT (ID,DOC_ID,ETAT_ID,OWNER,DATE_CREA,CODE,LIBELLE,CONFIG) VALUES (?,?,?,?,SYSDATE,?,?,?)");
int i = 1;
ps.setLong(i++, id);
ps.setString(i++, user.getId());
ps.setString(i++, cm.getCode());
ps.setString(i++, cm.getLibelle());
- byte[] buffer = cm.getConfigLines();
- InputStream is = new ByteArrayInputStream(buffer);
+ final byte[] buffer = cm.getConfigLines();
+ final InputStream is = new ByteArrayInputStream(buffer);
ps.setBinaryStream(i++, is, buffer.length);
ps.executeUpdate();
- } catch (Exception e) {
- logger.error("in insertConfigExport ", e);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("in insertConfigExport ", e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public void updateConfigExport(ConfigModel cm, XemeliosUser user) {
+ public void updateConfigExport(final ConfigModel cm, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
try {
int i = 1;
ps.setString(i++, cm.getCode());
ps.setString(i++, cm.getLibelle());
- byte[] buffer = cm.getConfigLines();
- InputStream is = new ByteArrayInputStream(buffer);
+ final byte[] buffer = cm.getConfigLines();
+ final InputStream is = new ByteArrayInputStream(buffer);
ps.setBinaryStream(i++, is, buffer.length);
ps.setString(i++, cm.getId());
ps.setString(i++, cm.getDocID());
ps.setString(i++, cm.getEtatID());
ps.executeUpdate();
- } catch (Exception e) {
- logger.error("in updateConfigExport ", e);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("in updateConfigExport ", e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<ConfigModel> getListeConfigsExport(String docID, String etatID, XemeliosUser user) {
+ public Vector<ConfigModel> getListeConfigsExport(final String docID, final String etatID, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
- Vector<ConfigModel> ret = new Vector<ConfigModel>();
- String dateFormat = getApplicationProperty(Constants.SYS_PROP_DATE_FORMAT);
+ final Vector<ConfigModel> ret = new Vector<ConfigModel>();
+ String dateFormat = this.getApplicationProperty(Constants.SYS_PROP_DATE_FORMAT);
if (dateFormat == null) {
dateFormat = "dd/MM/yyyy";
}
int i = 1;
ps.setString(i++, docID);
ps.setString(i++, etatID);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
ret.add(new ConfigModel(rs, dateFormat));
}
- } catch (Exception e) {
- logger.error("in getListeConfigsExport ", e);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("in getListeConfigsExport ", e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public ConfigModel getConfigExport(String docId, String etatId, String configId, XemeliosUser user) {
+ public ConfigModel getConfigExport(final String docId, final String etatId, final String configId, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
ConfigModel ret = null;
ps.setString(i++, docId);
ps.setString(i++, etatId);
ps.setString(i++, configId);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- ret = new ConfigModel(rs, getApplicationProperty(Constants.SYS_PROP_DATE_FORMAT));
+ ret = new ConfigModel(rs, this.getApplicationProperty(Constants.SYS_PROP_DATE_FORMAT));
}
- } catch (Exception e) {
- logger.error("in getConfigExport ", e);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("in getConfigExport ", e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public void deleteConfigExport(ConfigModel cm, XemeliosUser user) {
+ public void deleteConfigExport(final ConfigModel cm, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
try {
ps.setString(i++, cm.getDocID());
ps.setString(i++, cm.getEtatID());
ps.executeUpdate();
- } catch (Exception e) {
- logger.error("in deleteConfigExport ", e);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("in deleteConfigExport ", e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public ExportableData searchFichiers(DocumentModel dm, String coll, String budg, XemeliosUser user) throws DataAccessException, DataConfigurationException, UnauthorizedException {
+ public ExportableData searchFichiers(final DocumentModel dm, final String coll, final String budg, final XemeliosUser user) throws DataAccessException, DataConfigurationException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_EXPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des exports");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à exporter des " + dm.getTitre() + " pour cette collectivité");
}
ExportableData dD = null;
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
boolean found = false;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
- sb.append("SELECT " + pc.getCollectiviteCodeColname() + ", " + pc.getCollectiviteLibColname() + ", " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + ", " + pc.getInitialDocNameColname() + " FROM ").append(
- pc.getListBcTable().getBaseName());
+ final StringBuilder sb = new StringBuilder();
+ sb.append("SELECT " + pc.getCollectiviteCodeColname() + ", " + pc.getCollectiviteLibColname() + ", " + pc.getBudgetCodeColname() + ", " + pc.getBudgetLibColname() + ", " + pc.getInitialDocNameColname() + " FROM ").append(pc.getListBcTable().getBaseName());
if (coll != null) {
sb.append(" WHERE " + pc.getCollectiviteCodeColname() + "=? ");
}
if (budg != null) {
ps.setString(i++, budg);
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
String lastColl = "", lastBudg = "";
while (rs.next()) {
dD.setSelected(false);
}
found = true;
- String curColl = rs.getString(1);
- String curBudg = rs.getString(3);
+ final String curColl = rs.getString(1);
+ final String curBudg = rs.getString(3);
- ExportableData dF = new ExportableData();
+ final ExportableData dF = new ExportableData();
dF.setKey(dm.getId() + "|" + rs.getString(1) + "|" + rs.getString(3) + "|" + rs.getString(5));
dF.setLevel(ExportableData.LVL_FIC);
dF.setLibelle(rs.getString(5));
lastBudg = curBudg;
lastColl = curColl;
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<ExportableData> searchFichiers(DocumentsModel dms, String coll, String budg, XemeliosUser user) throws DataAccessException, DataConfigurationException, UnauthorizedException {
- Vector<ExportableData> ret = new Vector<ExportableData>();
- for (DocumentModel doc : dms.getDocuments()) {
+ public Vector<ExportableData> searchFichiers(final DocumentsModel dms, final String coll, final String budg, final XemeliosUser user) throws DataAccessException, DataConfigurationException, UnauthorizedException {
+ final Vector<ExportableData> ret = new Vector<ExportableData>();
+ for (final DocumentModel doc : dms.getDocuments()) {
try {
- ExportableData tmp = searchFichiers(doc, coll, budg, user);
+ final ExportableData tmp = this.searchFichiers(doc, coll, budg, user);
if (tmp != null) {
ret.add(tmp);
}
- } catch (DataAccessException dae) {
- if (!dae.getMessage().endsWith("doesn't exist"))
- {
+ } catch (final DataAccessException dae) {
+ if (!dae.getMessage().endsWith("doesn't exist")) {
throw dae;
}
}
}
@Override
- public DataResultSet getDataResultSetForExport(int whatToExport, ElementModel em, Pair coll, Pair budg, String fic, Pair SK1, Pair SK2, XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
+ public DataResultSet getDataResultSetForExport(final int whatToExport, final ElementModel em, final Pair coll, final Pair budg, final String fic, final Pair SK1, final Pair SK2, final XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_EXPORT)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des exports");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à exporter des " + em.getTitre());
}
if (!user.hasCollectivite(coll.key, em.getParent().getParent())) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + coll.libelle != null ? "(" + coll.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + em.getTitre() + " pour cette collectivité " + coll.libelle) != null ? "(" + coll.libelle + ")" : "");
}
- String sql = buildSelectToExport(whatToExport, em, coll, budg, fic, SK1, SK2, user);
- ListeResultatModel lrm = em.getListeResultat();
- OracleDataResultSet drs = new OracleDataResultSet(em, coll, budg, em.getPath().getPath(), sql, lrm, this, user);
+ final String sql = this.buildSelectToExport(whatToExport, em, coll, budg, fic, SK1, SK2, user);
+ final ListeResultatModel lrm = em.getListeResultat();
+ final OracleDataResultSet drs = new OracleDataResultSet(em, coll, budg, em.getPath().getPath(), sql, lrm, this, user);
return drs;
}
@Override
- public String getParameterValue(String paramName) {
+ public String getParameterValue(final String paramName) {
String ret = null;
Connection con = null;
PreparedStatement ps = null;
con = PoolManager.getInstance().getConnection();
ps = con.prepareStatement("SELECT PARAM_VALUE FROM PARAMETERS WHERE PARAM_NAME=?");
ps.setString(1, paramName);
- ResultSet rs = ps.executeQuery();
- if (rs.next())
+ final ResultSet rs = ps.executeQuery();
+ if (rs.next()) {
ret = rs.getString(1);
- } catch (Exception ex) {
- logger.error("getParameterValue(" + paramName + ")", ex);
+ }
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("getParameterValue(" + paramName + ")", ex);
} finally {
- if (con != null)
+ if (con != null) {
PoolManager.getInstance().releaseConnection(con);
+ }
}
return ret;
}
@Override
- public void setParameterValue(String paramName, String paramValue) {
+ public void setParameterValue(final String paramName, final String paramValue) {
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- String ret = getParameterValue(paramName);
+ final String ret = this.getParameterValue(paramName);
boolean prmExists = false;
- PreparedStatement psPrmExists = con.prepareStatement("SELECT 1 FROM PARAMETERS WHERE PARAM_NAME = ?");
+ final PreparedStatement psPrmExists = con.prepareStatement("SELECT 1 FROM PARAMETERS WHERE PARAM_NAME = ?");
try {
psPrmExists.setString(1, paramName);
- ResultSet rs = psPrmExists.executeQuery();
+ final ResultSet rs = psPrmExists.executeQuery();
prmExists = rs.next();
rs.close();
} finally {
ps.setString(1, paramValue);
ps.setString(2, paramName);
ps.executeUpdate();
- } catch (SQLException sqlEx) {
- logger.error("in getParameterValue", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("in getParameterValue", sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Object HSWinitTempStorage(String storageId, String keyId, int maxKeyLength, Vector<Field> fieldList) {
+ public Object HSWinitTempStorage(final String storageId, final String keyId, final int maxKeyLength, final Vector<Field> fieldList) {
// Parcours fieldList pour en deduire les types et les longiuers des
// champs
Class[] classes = null;
names = new String[fieldList.size()];
for (int i = 0; i < fieldList.size(); i++) {
- Field fld = fieldList.get(i);
- String typeName = fld.getType().toString();
+ final Field fld = fieldList.get(i);
+ final String typeName = fld.getType().toString();
LongueurMax anno;
if (typeName.equals("class java.lang.String")) {
names[i] = fld.getName();
}
}
- return HSWinitTempStorage(storageId, keyId, maxKeyLength, classes, sizes, names);
+ return this.HSWinitTempStorage(storageId, keyId, maxKeyLength, classes, sizes, names);
}
- private Object HSWinitTempStorage(String storageId, String keyId, int maxKeyLength, Class[] classes, int[] sizes, String names[]) {
+ private Object HSWinitTempStorage(final String storageId, final String keyId, final int maxKeyLength, final Class[] classes, final int[] sizes, final String names[]) {
Connection HSWcon = null;
- Hashtable<String, PreparedStatement> reqs = new Hashtable<String, PreparedStatement>();
- StringBuffer sqlCreateBuffer = new StringBuffer();
- StringBuffer sqlInsertBuffer = new StringBuffer();
- StringBuffer sqlInsertValuesBuffer = new StringBuffer();
- StringBuffer sqlSelectBuffer = new StringBuffer();
- StringBuffer sqlExistsBuffer = new StringBuffer();
- StringBuffer sqlCountBuffer = new StringBuffer();
- StringBuffer sqlDeleteBuffer = new StringBuffer();
- StringBuffer sqlDropBuffer = new StringBuffer();
- String virgule = ",";
+ final Hashtable<String, PreparedStatement> reqs = new Hashtable<String, PreparedStatement>();
+ final StringBuffer sqlCreateBuffer = new StringBuffer();
+ final StringBuffer sqlInsertBuffer = new StringBuffer();
+ final StringBuffer sqlInsertValuesBuffer = new StringBuffer();
+ final StringBuffer sqlSelectBuffer = new StringBuffer();
+ final StringBuffer sqlExistsBuffer = new StringBuffer();
+ final StringBuffer sqlCountBuffer = new StringBuffer();
+ final StringBuffer sqlDeleteBuffer = new StringBuffer();
+ final StringBuffer sqlDropBuffer = new StringBuffer();
+ final String virgule = ",";
sqlCreateBuffer.append("CREATE TABLE " + storageId + "(\n");
sqlInsertBuffer.append("INSERT INTO " + storageId + "(\n");
sqlInsertValuesBuffer.append("VALUES(\n");
sqlDeleteBuffer.append("WHERE " + keyId + " = ? ");
for (int i = 0; i < classes.length; i++) {
- Class cls = classes[i];
- Integer longueurMax = sizes[i];
+ final Class cls = classes[i];
+ final Integer longueurMax = sizes[i];
sqlCreateBuffer.append(virgule);
sqlCreateBuffer.append("\n");
sqlCreateBuffer.append(names[i] + " ");
sqlSelectBuffer.append("\n");
sqlSelectBuffer.append(names[i] + " ");
- String typeName = cls.toString();
+ final String typeName = cls.toString();
if (typeName.equals("class java.lang.String")) {
sqlCreateBuffer.append("VARCHAR(" + longueurMax.toString() + ")");
}
}
sqlCreateBuffer.append("\n)\n");
- String tableSpace = getParameterValue(TEMPORARY_TABLESPACE);
- if (tableSpace != null && tableSpace.length() > 0)
+ final String tableSpace = this.getParameterValue(OracleDataLayer.TEMPORARY_TABLESPACE);
+ if ((tableSpace != null) && (tableSpace.length() > 0)) {
sqlCreateBuffer.append(" tablespace ").append(tableSpace);
+ }
sqlInsertBuffer.append("\n)\n");
sqlInsertValuesBuffer.append("\n)\n");
try {
HSWcon = PoolManager.getInstance().getConnection();
- logger.debug(sqlCreateBuffer.toString());
- logger.debug(sqlInsertBuffer.toString() + sqlInsertValuesBuffer.toString());
- logger.debug(sqlExistsBuffer.toString());
- logger.debug(sqlDeleteBuffer.toString());
- logger.debug(sqlSelectBuffer.toString());
- logger.debug(sqlDropBuffer.toString());
- logger.debug(sqlCountBuffer.toString());
+ OracleDataLayer.logger.debug(sqlCreateBuffer.toString());
+ OracleDataLayer.logger.debug(sqlInsertBuffer.toString() + sqlInsertValuesBuffer.toString());
+ OracleDataLayer.logger.debug(sqlExistsBuffer.toString());
+ OracleDataLayer.logger.debug(sqlDeleteBuffer.toString());
+ OracleDataLayer.logger.debug(sqlSelectBuffer.toString());
+ OracleDataLayer.logger.debug(sqlDropBuffer.toString());
+ OracleDataLayer.logger.debug(sqlCountBuffer.toString());
reqs.put("Create", HSWcon.prepareStatement(sqlCreateBuffer.toString()));
reqs.put("Insert", HSWcon.prepareStatement(sqlInsertBuffer.toString() + sqlInsertValuesBuffer.toString()));
reqs.put("Exists", HSWcon.prepareStatement(sqlExistsBuffer.toString()));
reqs.put("Delete", HSWcon.prepareStatement(sqlDeleteBuffer.toString()));
reqs.put("Drop", HSWcon.prepareStatement(sqlDropBuffer.toString()));
reqs.put("Count", HSWcon.prepareStatement(sqlCountBuffer.toString()));
- } catch (SQLException se) {
- logger.error("init : SQL Exception:", se);
- } catch (Exception e) {
- logger.error("init: other exception", e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("init : SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error("init: other exception", e);
}
}
return new HSWStorageHandle(reqs, classes, HSWcon);
}
@Override
- public void HSWdoCreateStorage(Object pStorageHandle) {
+ public void HSWdoCreateStorage(final Object pStorageHandle) {
if (pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
try {
- PreparedStatement ps = ht.get("Create");// HSWcon.prepareStatement(sqlcreate);
+ final PreparedStatement ps = ht.get("Create");// HSWcon.prepareStatement(sqlcreate);
ps.executeUpdate();
- } catch (SQLException se) {
- logger.error("Create SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("Create SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
}
@Override
- public void HSWdoInsert(Object pStorageHandle, String key, Object[] values) {
+ public void HSWdoInsert(final Object pStorageHandle, final String key, final Object[] values) {
if (pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
try {
- PreparedStatement ps = ht.get("Insert"); // HSWcon.prepareStatement(sqlInsert);
+ final PreparedStatement ps = ht.get("Insert"); // HSWcon.prepareStatement(sqlInsert);
ps.setString(1, key);
for (int i = 0; i < values.length; ++i) {
- int j = i + 2;
+ final int j = i + 2;
if (values[i] instanceof String) {
ps.setString(j, (String) values[i]);
//
ps.setFloat(j, (Float) values[i]);
// S
} else if (values[i] instanceof java.util.Date) {
- java.sql.Date sqlDate = new java.sql.Date(((java.util.Date) values[i]).getTime());
+ final java.sql.Date sqlDate = new java.sql.Date(((java.util.Date) values[i]).getTime());
ps.setDate(j, sqlDate);
}
}
ps.executeUpdate();
- } catch (SQLException se) {
- logger.error("doInsert SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doInsert SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
}
@Override
- public boolean HSWdoExists(Object pStorageHandle, String key) {
+ public boolean HSWdoExists(final Object pStorageHandle, final String key) {
boolean ret = false;
PreparedStatement ps = null;
if (pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
try {
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
ps = ht.get("Exists");// HSWcon.prepareStatement(sqlexists);
ps.setString(1, key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
- int count = rs.getInt(1);
+ final int count = rs.getInt(1);
if (count > 0) {
ret = true;
}
}
- } catch (SQLException se) {
- logger.error("doExists SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doExists SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
return ret;
}
@Override
- public Object[] HSWdoSelect(Object pStorageHandle, String key, Object[] inoutObj) {
+ public Object[] HSWdoSelect(final Object pStorageHandle, final String key, final Object[] inoutObj) {
Object[] ret = null;
if (pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
PreparedStatement ps = null;
try {
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
- Class[] classes = storageHandle.classes;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final Class[] classes = storageHandle.classes;
ps = ht.get("Select"); // HSWcon.prepareStatement(sqlselect);
ps.setString(1, key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
for (int i = 0; i < classes.length; i++) {
- int j = i + 2;
- Class cls = classes[i];
- String typeName = cls.toString();
+ final int j = i + 2;
+ final Class cls = classes[i];
+ final String typeName = cls.toString();
if (typeName.equals("class java.lang.String")) {
inoutObj[i] = rs.getString(j);
inoutObj[i] = rs.getDouble(j);
} else if (typeName.equals("class java.util.Date")) {
- java.sql.Date sqlDate = rs.getDate(j);
+ final java.sql.Date sqlDate = rs.getDate(j);
inoutObj[i] = sqlDate;
}
}
ret = inoutObj;
}
- } catch (SQLException se) {
- logger.error("doSelect SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doSelect SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
return ret;
}
@Override
- public boolean HSWdoDelete(Object pStorageHandle, String key) {
+ public boolean HSWdoDelete(final Object pStorageHandle, final String key) {
boolean ret = false;
if (pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
PreparedStatement ps = null;
try {
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
ps = ht.get("Delete");// HSWcon.prepareStatement(sqldelete);
ps.setString(1, key);
ps.executeUpdate();
ret = true;
- } catch (SQLException se) {
- logger.error("doDelete SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doDelete SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
return ret;
}
@Override
- public int HSWdoCount(Object pStorageHandle) {
+ public int HSWdoCount(final Object pStorageHandle) {
int ret = -1;
- if (pStorageHandle != null && pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ if ((pStorageHandle != null) && (pStorageHandle instanceof HSWStorageHandle)) {
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
PreparedStatement ps = null;
try {
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
ps = ht.get("Count");
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = rs.getInt(1);
}
- } catch (SQLException se) {
- logger.error("doCount SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doCount SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
}
}
return ret;
}
@Override
- public boolean HSWdoDrop(Object pStorageHandle) {
- boolean ret = false;
- if (pStorageHandle != null && pStorageHandle instanceof HSWStorageHandle) {
- HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
+ public boolean HSWdoDrop(final Object pStorageHandle) {
+ final boolean ret = false;
+ if ((pStorageHandle != null) && (pStorageHandle instanceof HSWStorageHandle)) {
+ final HSWStorageHandle storageHandle = (HSWStorageHandle) pStorageHandle;
Connection HSWcon = null;
PreparedStatement ps = null;
try {
- Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
+ final Hashtable<String, PreparedStatement> ht = storageHandle.requetes;
ps = ht.get("Drop"); // HSWcon.prepareStatement(sqldrop);
HSWcon = storageHandle.con;
ps.executeUpdate();
- } catch (SQLException se) {
- logger.error("doDrop : SQL Exception:", se);
- } catch (Exception e) {
- logger.error(e);
+ } catch (final SQLException se) {
+ OracleDataLayer.logger.error("doDrop : SQL Exception:", se);
+ } catch (final Exception e) {
+ OracleDataLayer.logger.error(e);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (HSWcon != null) {
if (pos > url.length()) {
pos = url.length();
}
- String server = url.substring(0, pos);
+ final String server = url.substring(0, pos);
try {
- InetAddress serverAddress = InetAddress.getByName(server);
- InetAddress localAddress = InetAddress.getLocalHost();
+ final InetAddress serverAddress = InetAddress.getByName(server);
+ final InetAddress localAddress = InetAddress.getLocalHost();
return localAddress.equals(serverAddress);
- } catch (UnknownHostException uhEx) {
- logger.error(null, uhEx);
+ } catch (final UnknownHostException uhEx) {
+ OracleDataLayer.logger.error(null, uhEx);
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
// ca devrait vraiment pas arriver !
} finally {
- if (con != null)
+ if (con != null) {
PoolManager.getInstance().releaseConnection(con);
+ }
}
return false;
}
@Override
- public Vector<Pair> getListeCodeLibelleRepository(DocumentModel dm, Pair collectivite, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Pair> getListeCodeLibelleRepository(final DocumentModel dm, final Pair collectivite, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Pair> ret = new Vector<Pair>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Pair> ret = new Vector<Pair>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT ID, LIBELLE FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
String code = rs.getString(1);
if (rs.wasNull()) {
}
ret.add(new Pair(code, libelle));
}
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
throw new DataAccessException(sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public Vector<Document> getRepositorysAsDom(DocumentModel dm, Pair collectivite, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public Vector<Document> getRepositorysAsDom(final DocumentModel dm, final Pair collectivite, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre());
}
if (!user.hasCollectivite(collectivite.key, dm)) {
- throw new UnauthorizedException("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle != null ? "(" + collectivite.libelle + ")" : "");
+ throw new UnauthorizedException(("Vous n'êtes pas autorisé à rechercher des " + dm.getTitre() + " pour cette collectivité " + collectivite.libelle) != null ? "(" + collectivite.libelle + ")" : "");
}
- Vector<Document> vRet = new Vector<Document>();
- TDocument pc = getPersistenceConfig(dm, user).getLayer(getLayerName()).getDocument(dm.getId());
+ final Vector<Document> vRet = new Vector<Document>();
+ final TDocument pc = this.getPersistenceConfig(dm, user).getLayer(this.getLayerName()).getDocument(dm.getId());
Connection con = null;
PreparedStatement ps = null;
try {
con = PoolManager.getInstance().getConnection();
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT REPOSITORY FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
Document doc;
- InputStream docIn = getReadableInputStream(rs.getBinaryStream(1));
+ final InputStream docIn = this.getReadableInputStream(rs.getBinaryStream(1));
try {
- doc = parseDOMFromInputStream(domFactory, docIn);
+ doc = this.parseDOMFromInputStream(this.domFactory, docIn);
} finally {
docIn.close();
}
vRet.add(doc);
- if ("true".equals(getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
- TransformerFactory tf = FactoryProvider.getTransformerFactory();
- Transformer t = tf.newTransformer();
- ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
+ if ("true".equals(this.getApplicationProperty(Constants.SYS_PROP_LOG_DOM_DOC))) {
+ final TransformerFactory tf = FactoryProvider.getTransformerFactory();
+ final Transformer t = tf.newTransformer();
+ final ByteArrayOutputStream baos2 = new ByteArrayOutputStream();
t.transform(new DOMSource(doc), new StreamResult(baos2));
- logger.debug(new String(baos2.toByteArray()));
+ OracleDataLayer.logger.debug(new String(baos2.toByteArray()));
}
}
- } catch (Throwable t) {
+ } catch (final Throwable t) {
throw new DataConfigurationException("invalid code !", t);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
if (con != null) {
}
@Override
- public String getLastInputValue(String inputId, XemeliosUser user) {
+ public String getLastInputValue(final String inputId, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
String ret = null;
ps = con.prepareStatement("SELECT VALUE FROM LAST_INPUT_VALUES WHERE USER_ID=? AND INPUT_ID=?");
ps.setString(1, user.getId());
ps.setString(2, inputId);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = rs.getString(1);
}
rs.close();
- } catch (SQLException sqlEx) {
- logger.error("getLastInputValue(String,XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("getLastInputValue(String,XemeliosUser)", sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException sqlEx) {
- logger.info("getLastInputValue(String,XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.info("getLastInputValue(String,XemeliosUser)", sqlEx);
}
}
if (con != null) {
}
@Override
- public void setLastInputValue(String inputId, String value, XemeliosUser user) {
+ public void setLastInputValue(final String inputId, final String value, final XemeliosUser user) {
Connection con = null;
PreparedStatement ps = null;
try {
ps.setString(1, value);
ps.setString(2, user.getId());
ps.setString(3, inputId);
- int ret = ps.executeUpdate();
+ final int ret = ps.executeUpdate();
if (ret == 0) {
// la ligne n'était pas présente
ps.close();
ps.setString(3, value);
ps.executeUpdate();
}
- } catch (SQLException sqlEx) {
- logger.error("setLastInputValue(String,String,XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("setLastInputValue(String,String,XemeliosUser)", sqlEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException sqlEx) {
- logger.info("setLastInputValue(String,String,XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.info("setLastInputValue(String,String,XemeliosUser)", sqlEx);
}
}
if (con != null) {
}
@Override
- public void saveRequest(ElementModel em, RechercheModel recherche, XemeliosUser user) {
- String key = em.getKey();
+ public void saveRequest(final ElementModel em, final RechercheModel recherche, final XemeliosUser user) {
+ final String key = em.getKey();
Connection con = null;
PreparedStatement ps = null;
try {
sql = "UPDATE SAVED_REQUESTS SET REQUEST=? WHERE KEY_EM=? AND USER_ID=? AND TITLE=? AND ID=?";
}
ps = con.prepareStatement(sql);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Charset cs = Charset.forName("ISO-8859-1");
- OutputStreamWriter out = new OutputStreamWriter(baos, cs);
- XmlOutputter outputter = new XmlOutputter(out, cs.name());
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final Charset cs = Charset.forName("ISO-8859-1");
+ final OutputStreamWriter out = new OutputStreamWriter(baos, cs);
+ final XmlOutputter outputter = new XmlOutputter(out, cs.name());
recherche.marshall(outputter);
out.flush();
out.close();
- InputStream is = new ByteArrayInputStream(baos.toByteArray());
+ final InputStream is = new ByteArrayInputStream(baos.toByteArray());
ps.setBinaryStream(1, is, baos.size());
ps.setString(2, key);
ps.setString(3, user.getId());
ps.setString(4, recherche.getDisplayName());
ps.setString(5, recherche.getId());
- int ret = ps.executeUpdate();
+ final int ret = ps.executeUpdate();
if (ret != 1) {
throw new SQLException("unexpected update result: " + ret + " row(s) updated, only 1 expected");
}
- } catch (Exception ex) {
- logger.error("saveRequest(ElementModel,RechercheModel,XemeliosUser)", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("saveRequest(ElementModel,RechercheModel,XemeliosUser)", ex);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException sqlEx) {
- logger.info("saveRequest(ElementModel,RechercheModel,XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.info("saveRequest(ElementModel,RechercheModel,XemeliosUser)", sqlEx);
}
}
if (con != null) {
}
@Override
- public List<RechercheModel> getSavedRequests(ElementModel em, XemeliosUser user, boolean includePublics) {
- ArrayList<RechercheModel> ret = new ArrayList<RechercheModel>();
- String key = em.getKey();
- StringBuffer sql = new StringBuffer("SELECT REQUEST FROM SAVED_REQUESTS WHERE KEY_EM=? AND ");
+ public List<RechercheModel> getSavedRequests(final ElementModel em, final XemeliosUser user, final boolean includePublics) {
+ final ArrayList<RechercheModel> ret = new ArrayList<RechercheModel>();
+ final String key = em.getKey();
+ final StringBuffer sql = new StringBuffer("SELECT REQUEST FROM SAVED_REQUESTS WHERE KEY_EM=? AND ");
if (includePublics) {
sql.append("(USER_ID=? OR PUBLIC=1)");
ps = con.prepareStatement(sql.toString());
ps.setString(1, key);
ps.setString(2, user.getId());
- ResultSet rs = ps.executeQuery();
- PersonnalConfigParser pcp = new PersonnalConfigParser();
+ final ResultSet rs = ps.executeQuery();
+ final PersonnalConfigParser pcp = new PersonnalConfigParser();
while (rs.next()) {
- InputStream is = rs.getBinaryStream(1);
+ final InputStream is = rs.getBinaryStream(1);
// ByteArrayOutputStream baos = new ByteArrayOutputStream();
// InputStreamLogger wrapper = new InputStreamLogger(is, baos);
pcp.parse(is);
- RechercheModel rm = (RechercheModel) pcp.getMarshallable();
+ final RechercheModel rm = (RechercheModel) pcp.getMarshallable();
ret.add(rm);
// logger.debug(baos.toString("ISO-8859-1"));
}
- } catch (SQLException sqlEx) {
- logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", sqlEx);
- } catch (SAXException saxEx) {
- logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", saxEx);
- } catch (ParserConfigurationException pcEx) {
- logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", pcEx);
- } catch (IOException ioEx) {
- logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", ioEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", sqlEx);
+ } catch (final SAXException saxEx) {
+ OracleDataLayer.logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", saxEx);
+ } catch (final ParserConfigurationException pcEx) {
+ OracleDataLayer.logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", pcEx);
+ } catch (final IOException ioEx) {
+ OracleDataLayer.logger.error("getSavedRequests(ElementModel,XemeliosUser,boolean)", ioEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException sqlEx) {
- logger.info("getSavedRequests(ElementModel,XemeliosUser,boolean)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.info("getSavedRequests(ElementModel,XemeliosUser,boolean)", sqlEx);
}
}
if (con != null) {
}
@Override
- public RechercheModel getSavedRequest(ElementModel em, XemeliosUser user, String searchId) {
+ public RechercheModel getSavedRequest(final ElementModel em, final XemeliosUser user, final String searchId) {
RechercheModel ret = null;
- String key = em.getKey();
- StringBuffer sql = new StringBuffer("SELECT REQUEST FROM SAVED_REQUESTS WHERE KEY_EM=? AND ID=?");
+ final String key = em.getKey();
+ final StringBuffer sql = new StringBuffer("SELECT REQUEST FROM SAVED_REQUESTS WHERE KEY_EM=? AND ID=?");
Connection con = null;
PreparedStatement ps = null;
try {
ps = con.prepareStatement(sql.toString());
ps.setString(1, key);
ps.setString(2, searchId);
- ResultSet rs = ps.executeQuery();
- PersonnalConfigParser pcp = new PersonnalConfigParser();
+ final ResultSet rs = ps.executeQuery();
+ final PersonnalConfigParser pcp = new PersonnalConfigParser();
if (rs.next()) {
- InputStream is = rs.getBinaryStream(1);
+ final InputStream is = rs.getBinaryStream(1);
pcp.parse(is);
ret = (RechercheModel) pcp.getMarshallable();
}
- } catch (SQLException sqlEx) {
- logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", sqlEx);
- } catch (SAXException saxEx) {
- logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", saxEx);
- } catch (ParserConfigurationException pcEx) {
- logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", pcEx);
- } catch (IOException ioEx) {
- logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", ioEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", sqlEx);
+ } catch (final SAXException saxEx) {
+ OracleDataLayer.logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", saxEx);
+ } catch (final ParserConfigurationException pcEx) {
+ OracleDataLayer.logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", pcEx);
+ } catch (final IOException ioEx) {
+ OracleDataLayer.logger.error("getSavedRequest(ElementModel,XemeliosUser,String)", ioEx);
} finally {
if (ps != null) {
try {
ps.close();
- } catch (SQLException sqlEx) {
- logger.info("getSavedRequest(ElementModel,XemeliosUser,String)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.info("getSavedRequest(ElementModel,XemeliosUser,String)", sqlEx);
}
}
if (con != null) {
@Override
public void shutdown() {
- reset();
+ this.reset();
PoolManager.getInstance().shutdown();
}
@Override
- public byte[] serializeDataResultSet(DataResultSet drs) {
+ public byte[] serializeDataResultSet(final DataResultSet drs) {
if (drs instanceof OracleDataResultSet) {
try {
- DataResultSetWrapperModel drsw = new DataResultSetWrapperModel(DataResultSetWrapperModel.QN);
+ final DataResultSetWrapperModel drsw = new DataResultSetWrapperModel(DataResultSetWrapperModel.QN);
drsw.setDataResultSet(drs);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Charset cs = Charset.forName("UTF-8");
- OutputStreamWriter osw = new OutputStreamWriter(baos, cs);
- XmlOutputter output = new XmlOutputter(osw, cs.name());
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final Charset cs = Charset.forName("UTF-8");
+ final OutputStreamWriter osw = new OutputStreamWriter(baos, cs);
+ final XmlOutputter output = new XmlOutputter(osw, cs.name());
drsw.marshall(output);
osw.flush();
return baos.toByteArray();
- } catch (IOException ex) {
- logger.error("serializeDataResultSet(DataResultSet)", ex);
+ } catch (final IOException ex) {
+ OracleDataLayer.logger.error("serializeDataResultSet(DataResultSet)", ex);
return null;
}
} else {
}
@Override
- public DataResultSet deserializeDataResultSet(byte[] buffer) {
+ public DataResultSet deserializeDataResultSet(final byte[] buffer) {
try {
- DrswParser parser = new DrswParser();
+ final DrswParser parser = new DrswParser();
parser.parse(new ByteArrayInputStream(buffer));
- DataResultSetWrapperModel drsw = (DataResultSetWrapperModel) parser.getMarshallable();
+ final DataResultSetWrapperModel drsw = (DataResultSetWrapperModel) parser.getMarshallable();
return drsw.getDataResultSet();
- } catch (Exception ex) {
- logger.error("deserializeDataResultSet(byte[])", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("deserializeDataResultSet(byte[])", ex);
return null;
}
}
@Override
- public void createExportJob(ExportJob job, XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public void createExportJob(final ExportJob job, final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_EXPORT)) {
throw new UnauthorizedException("Vous n'avez pas les droits pour réaliser des exports.");
}
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- String sql = "INSERT INTO EXPORT_JOBS (UTI_LOGIN, EXPORT_ID, FILE_NAME,EXPORT_NAME,DOC_ID,ETAT_ID,ELEMENT_ID,CONFIG_ID,EXPORT_SIZE,EXPORT_STATUS,SUBMIT_DATE,DRS) VALUES (?,SQ_EXPORTS_JOBS.nextval,?,?,?,?,?,?,?,?,SYSDATE,?)";
- PreparedStatement ps = con.prepareStatement(sql);
+ final String sql = "INSERT INTO EXPORT_JOBS (UTI_LOGIN, EXPORT_ID, FILE_NAME,EXPORT_NAME,DOC_ID,ETAT_ID,ELEMENT_ID,CONFIG_ID,EXPORT_SIZE,EXPORT_STATUS,SUBMIT_DATE,DRS) VALUES (?,SQ_EXPORTS_JOBS.nextval,?,?,?,?,?,?,?,?,SYSDATE,?)";
+ final PreparedStatement ps = con.prepareStatement(sql);
int i = 1;
ps.setString(i++, user.getId());
ps.setString(i++, job.getFileName());
ps.setLong(i++, job.getExportConfigId());
ps.setInt(i++, job.getSize());
ps.setInt(i++, ExportJob.STATUS_SUBMIT);
- byte[] buffer = job.getDrs();
+ final byte[] buffer = job.getDrs();
ps.setBinaryStream(i++, new ByteArrayInputStream(buffer), buffer.length);
ps.executeUpdate();
ps.close();
- } catch (Exception ex) {
- logger.error("createExportJob(ExportJob,XemeliosUser)", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("createExportJob(ExportJob,XemeliosUser)", ex);
throw new DataAccessException(ex);
} finally {
if (con != null) {
}
@Override
- public List<ExportJob> getExportJobList(XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
- ArrayList<ExportJob> ret = new ArrayList<ExportJob>();
+ public List<ExportJob> getExportJobList(final XemeliosUser user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ final ArrayList<ExportJob> ret = new ArrayList<ExportJob>();
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, "
- + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, " + "GENERATED_FILE_NAME, " + "CLEANED, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE UTI_LOGIN=? " + "AND (DOWNLOAD_DATE IS NULL OR DOWNLOAD_DATE<(SYSDATE+7)) AND CLEANED IS NULL";
- PreparedStatement ps = con.prepareStatement(sql);
+ final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, " + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, "
+ + "GENERATED_FILE_NAME, " + "CLEANED, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE UTI_LOGIN=? " + "AND (DOWNLOAD_DATE IS NULL OR DOWNLOAD_DATE<(SYSDATE+7)) AND CLEANED IS NULL";
+ final PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, user.getId());
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
ret.add(new ExportJobImpl(rs, false));
}
- } catch (SQLException sqlEx) {
- logger.error("getExportJobs(XemeliosUser)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("getExportJobs(XemeliosUser)", sqlEx);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
@Override
- public ExportJob getExportJob(long exportId, String user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
+ public ExportJob getExportJob(final long exportId, final String user) throws DataConfigurationException, DataAccessException, UnauthorizedException {
ExportJob ret = null;
Connection con = null;
try {
con = PoolManager.getInstance().getConnection();
- String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, "
- + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, " + "GENERATED_FILE_NAME, " + "CLEANED, " + "DRS, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE EXPORT_ID=? " + "AND UTI_LOGIN=?";
- PreparedStatement ps = con.prepareStatement(sql);
+ final String sql = "SELECT " + "EXPORT_ID, " + "FILE_NAME, " + "EXPORT_NAME, " + "DOC_ID, " + "ETAT_ID, " + "ELEMENT_ID, " + "CONFIG_ID, " + "EXPORT_SIZE, " + "PRIORITY, " + "EXPORT_STATUS, " + "SUBMIT_DATE, " + "RUN_DATE, " + "DOWNLOAD_DATE, " + "ERROR_MESSAGE, "
+ + "GENERATED_FILE_NAME, " + "CLEANED, " + "DRS, " + "UTI_LOGIN " + "FROM EXPORT_JOBS " + "WHERE EXPORT_ID=? " + "AND UTI_LOGIN=?";
+ final PreparedStatement ps = con.prepareStatement(sql);
ps.setLong(1, exportId);
ps.setString(2, user);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
ret = new ExportJobImpl(rs, true);
}
- } catch (SQLException sqlEx) {
- logger.error("getExportJob(exportId,user)", sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("getExportJob(exportId,user)", sqlEx);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
@Override
public String getWarnings() {
- StringBuilder sb = warnings.remove(Thread.currentThread());
+ final StringBuilder sb = this.warnings.remove(Thread.currentThread());
return sb.toString();
}
}
@Override
- public void setApplicationProperties(PropertiesExpansion applicationProperties) {
+ public void setApplicationProperties(final PropertiesExpansion applicationProperties) {
this.applicationProperties = applicationProperties;
}
@Override
- public Hashtable<String, Object> getRedefinedConfigValues(XemeliosUser user) throws DataConfigurationException, DataAccessException {
- Hashtable<String, Object> ret = new Hashtable<String, Object>();
+ public Hashtable<String, Object> getRedefinedConfigValues(final XemeliosUser user) throws DataConfigurationException, DataAccessException {
+ final Hashtable<String, Object> ret = new Hashtable<String, Object>();
Connection con = null;
try {
- DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
- XPath xp = xPathFactory.newXPath();
+ final DocumentBuilder domBuilder = this.domFactory.newDocumentBuilder();
+ final XPath xp = this.xPathFactory.newXPath();
con = PoolManager.getInstance().getConnection();
- PreparedStatement ps = con.prepareStatement("SELECT ELEMENT FROM XML_CONFIG_ELEMENTS WHERE ELEMENT_ID=? AND UTI_LOGIN=?");
- ps.setString(1, ELEMENT_DOC_CONFIGS_OVR);
+ final PreparedStatement ps = con.prepareStatement("SELECT ELEMENT FROM XML_CONFIG_ELEMENTS WHERE ELEMENT_ID=? AND UTI_LOGIN=?");
+ ps.setString(1, OracleDataLayer.ELEMENT_DOC_CONFIGS_OVR);
ps.setString(2, user.getId());
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
while (rs.next()) {
- InputStream is = rs.getBinaryStream(1);
- Document dom = domBuilder.parse(is);
- NodeList els = (NodeList) xp.evaluate("/overriden/value", dom, XPathConstants.NODESET);
+ final InputStream is = rs.getBinaryStream(1);
+ final Document dom = domBuilder.parse(is);
+ final NodeList els = (NodeList) xp.evaluate("/overriden/value", dom, XPathConstants.NODESET);
for (int i = 0; i < els.getLength(); i++) {
- Element el = (Element) els.item(i);
+ final Element el = (Element) els.item(i);
ret.put(el.getAttribute("path"), el.getAttribute("value"));
}
}
- } catch (Exception sqlEx) {
- logger.error("getRedefinedConfigValues(" + user.getId() + ")", sqlEx);
+ } catch (final Exception sqlEx) {
+ OracleDataLayer.logger.error("getRedefinedConfigValues(" + user.getId() + ")", sqlEx);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
@Override
- public void saveRedefinedValues(Hashtable<String, Object> valuesToSet, List<String> valuesToUnset, XemeliosUser user) throws DataConfigurationException, DataAccessException {
- Hashtable<String, Object> ret = getRedefinedConfigValues(user);
+ public void saveRedefinedValues(final Hashtable<String, Object> valuesToSet, final List<String> valuesToUnset, final XemeliosUser user) throws DataConfigurationException, DataAccessException {
+ final Hashtable<String, Object> ret = this.getRedefinedConfigValues(user);
ret.putAll(valuesToSet);
- for (String key : valuesToUnset) {
+ for (final String key : valuesToUnset) {
ret.remove(key);
}
Connection con = null;
try {
- DocumentBuilder domBuilder = domFactory.newDocumentBuilder();
- Document dom = domBuilder.newDocument();
- Element root = dom.createElement("overriden");
+ final DocumentBuilder domBuilder = this.domFactory.newDocumentBuilder();
+ final Document dom = domBuilder.newDocument();
+ final Element root = dom.createElement("overriden");
dom.appendChild(root);
- for (String key : ret.keySet()) {
- Element el = dom.createElement("value");
+ for (final String key : ret.keySet()) {
+ final Element el = dom.createElement("value");
el.setAttribute("path", key);
el.setAttribute("value", ret.get(key).toString());
root.appendChild(el);
}
con = PoolManager.getInstance().getConnection();
PreparedStatement ps = con.prepareStatement("DELETE FROM XML_CONFIG_ELEMENTS WHERE ELEMENT_ID=? AND UTI_LOGIN=?");
- ps.setString(1, ELEMENT_DOC_CONFIGS_OVR);
+ ps.setString(1, OracleDataLayer.ELEMENT_DOC_CONFIGS_OVR);
ps.setString(2, user.getId());
ps.executeUpdate();
ps = con.prepareStatement("INSERT INTO XML_CONFIG_ELEMENTS (ELEMENT_ID, UTI_LOGIN, ELEMENT) VALUES (?,?,?)");
- ps.setString(1, ELEMENT_DOC_CONFIGS_OVR);
+ ps.setString(1, OracleDataLayer.ELEMENT_DOC_CONFIGS_OVR);
ps.setString(2, user.getId());
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- TransformerFactory tFactory = FactoryProvider.getTransformerFactory();
- Transformer t = tFactory.newTransformer();
+ final ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ final TransformerFactory tFactory = FactoryProvider.getTransformerFactory();
+ final Transformer t = tFactory.newTransformer();
t.transform(new DOMSource(dom), new StreamResult(baos));
- byte[] buffer = baos.toByteArray();
- ByteArrayInputStream is = new ByteArrayInputStream(buffer);
+ final byte[] buffer = baos.toByteArray();
+ final ByteArrayInputStream is = new ByteArrayInputStream(buffer);
ps.setBinaryStream(3, is, buffer.length);
ps.executeUpdate();
- } catch (Exception sqlEx) {
- logger.error("saveRedefinedConfigValues(...," + user.getId() + ")", sqlEx);
+ } catch (final Exception sqlEx) {
+ OracleDataLayer.logger.error("saveRedefinedConfigValues(...," + user.getId() + ")", sqlEx);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
@Override
- public void declareArchiveImported(String archiveName, XemeliosUser user) throws DataConfigurationException, UnauthorizedException {
+ public void declareArchiveImported(final String archiveName, final XemeliosUser user) throws DataConfigurationException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_IMPORT)) {
throw new UnauthorizedException(user.getDisplayName() + " (" + user.getId() + ") n'est pas autorisé à réaliser des imports");
}
ps.setString(2, user.getId());
ps.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
ps.executeUpdate();
- } catch (Exception ex) {
- logger.error("declareArchiveImported(" + archiveName + "," + user.getId() + ")", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.error("declareArchiveImported(" + archiveName + "," + user.getId() + ")", ex);
} finally {
if (con != null) {
PoolManager.getInstance().releaseConnection(con);
}
@Override
- public boolean canImportDocument(String documentId, XemeliosUser user) throws UnauthorizedException {
+ public boolean canImportDocument(final String documentId, final XemeliosUser user) throws UnauthorizedException {
boolean ret = false;
// a priori, sous oracle, on n'a pas besoin de patcher, donc c'est
// seulement les droits de l'utilisateur
}
@Override
- public String getInitialDocNameFromDocId(EtatModel em, String collectivite, String budget, String docId, Connection con, XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
+ public String getInitialDocNameFromDocId(final EtatModel em, final String collectivite, final String budget, final String docId, final Connection con, final XemeliosUser user) throws DataConfigurationException, SQLException, UnauthorizedException {
if (!user.hasRole(XemeliosUser.ROLE_SEARCH)) {
throw new UnauthorizedException("Vous n'êtes pas autorisé à faire des recherches");
}
String ret = "";
- TDocument pc = getPersistenceConfig(em.getParent(), user).getLayer(getLayerName()).getDocument(em.getParent().getId());
- TEtat sec = pc.getEtat(em.getId());
- StringBuilder sb = new StringBuilder("SELECT INITIAL_DOC_NAME FROM " + sec.getMaintable().getBaseName() + " WHERE COLLECTIVITE=? AND BUDGET=? AND DOC_ID=?");
+ final TDocument pc = this.getPersistenceConfig(em.getParent(), user).getLayer(this.getLayerName()).getDocument(em.getParent().getId());
+ final TEtat sec = pc.getEtat(em.getId());
+ final StringBuilder sb = new StringBuilder("SELECT INITIAL_DOC_NAME FROM " + sec.getMaintable().getBaseName() + " WHERE COLLECTIVITE=? AND BUDGET=? AND DOC_ID=?");
PreparedStatement ps = con.prepareStatement(sb.toString());
ps = con.prepareStatement(sb.toString());
ps.setString(1, collectivite);
ps.setString(2, budget);
ps.setString(3, docId);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
if (rs.next()) {
ret = rs.getString(1);
}
}
// méthodes non requises par l'héritage
- private boolean isTableExists(String tableName, Connection con) {
+ private boolean isTableExists(final String tableName, final Connection con) {
Statement st = null;
try {
st = con.createStatement();
st.executeQuery("SELECT 1 FROM " + tableName).close();
return true;
- } catch (Exception ex) {
+ } catch (final Exception ex) {
return false;
} finally {
if (st != null) {
try {
st.close();
- } catch (Exception ex) {
- logger.warn("isTableExists().closing st", ex);
+ } catch (final Exception ex) {
+ OracleDataLayer.logger.warn("isTableExists().closing st", ex);
}
}
}
}
private static String[] splitConditions(final String cond) throws DataConfigurationException {
- ArrayList<String> ret = new ArrayList<String>();
+ final ArrayList<String> ret = new ArrayList<String>();
String s = cond;
- while (s.length() > 0 && s.charAt(0) == '[') {
- int end = findClosingParenthesis(s, 0, "[]");
+ while ((s.length() > 0) && (s.charAt(0) == '[')) {
+ final int end = OracleDataLayer.findClosingParenthesis(s, 0, "[]");
ret.add(s.substring(0, end + 1));
s = s.substring(end + 1);
}
- String aRet[] = new String[ret.size()];
+ final String aRet[] = new String[ret.size()];
ret.toArray(aRet);
return aRet;
}
- protected String buildSelectToExport(int whatToExport, ElementModel elementModel, Pair coll, Pair budg, String fic, Pair sk1, Pair sk2, XemeliosUser user) throws DataConfigurationException {
- EtatModel etatModel = elementModel.getParent();
- DocumentModel documentModel = etatModel.getParent();
- TDocument pc = getPersistenceConfig(documentModel, user).getLayer(getLayerName()).getDocument(documentModel.getId());
- TEtat sec = pc.getEtat(etatModel.getId());
- TTable docTable = sec.getDocumentTable();
- StringBuffer sb = new StringBuffer();
+ protected String buildSelectToExport(final int whatToExport, final ElementModel elementModel, final Pair coll, final Pair budg, final String fic, final Pair sk1, final Pair sk2, final XemeliosUser user) throws DataConfigurationException {
+ final EtatModel etatModel = elementModel.getParent();
+ final DocumentModel documentModel = etatModel.getParent();
+ final TDocument pc = this.getPersistenceConfig(documentModel, user).getLayer(this.getLayerName()).getDocument(documentModel.getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
+ final TTable docTable = sec.getDocumentTable();
+ final StringBuffer sb = new StringBuffer();
switch (whatToExport) {
case EXPORT_BUD: {
sb.append("SELECT ").append(docTable.getBaseName()).append(".DOC_ID FROM ").append(docTable.getBaseName());
}
private ResourceBundle getMessages() {
- if (messages == null)
- messages = ResourceBundle.getBundle(RESOURCE_BASE_NAME);
- return messages;
+ if (this.messages == null) {
+ this.messages = ResourceBundle.getBundle(OracleDataLayer.RESOURCE_BASE_NAME);
+ }
+ return this.messages;
}
/**
* @throws ParsingException
* if no closing parenthesis were found.
*/
- private static int findClosingParenthesis(String expr, int first, String delimitors) throws DataConfigurationException {
+ private static int findClosingParenthesis(final String expr, final int first, final String delimitors) throws DataConfigurationException {
final char OPENNING_DELIM = delimitors.charAt(0);
final char CLOSING_DELIM = delimitors.charAt(1);
- int len = expr.length();
+ final int len = expr.length();
int close = -1;
int pCount = 1;
for (int i = (first + 1); i < len; i++) {
- char c = expr.charAt(i);
+ final char c = expr.charAt(i);
if (c == OPENNING_DELIM) {
pCount++;
} else if (c == CLOSING_DELIM) {
* @param con
* @throws SQLException
*/
- private void ensureTablesExists(TDocument pc, TEtat sec, /*
- * Pair codeBudget, Pair collectivite,
- */Connection con) throws SQLException {
- Statement st = con.createStatement();
- createTable(pc.getListBcTable(), st);
- createTable(pc.getRepositoryTable(), st);
- createTable(pc.getSpecialKeyTable(), st);
+ private void ensureTablesExists(final TDocument pc, final TEtat sec, /*
+ * Pair codeBudget, Pair collectivite,
+ */final Connection con) throws SQLException {
+ final Statement st = con.createStatement();
+ this.createTable(pc.getListBcTable(), st);
+ this.createTable(pc.getRepositoryTable(), st);
+ this.createTable(pc.getSpecialKeyTable(), st);
- createTable(sec.getDocumentTable(), st);
- for (TTable table : sec.getIndexTables()) {
- createTable(table, st);
+ this.createTable(sec.getDocumentTable(), st);
+ for (final TTable table : sec.getIndexTables()) {
+ this.createTable(table, st);
}
- for (TTable table : sec.getOtherTables()) {
- createTable(table, st);
+ for (final TTable table : sec.getOtherTables()) {
+ this.createTable(table, st);
}
st.close();
}
* @param st
* @throws SQLException
*/
- private void createTable(TTable sti, Statement st) throws SQLException {
+ private void createTable(final TTable sti, final Statement st) throws SQLException {
if (sti == null) {
return;
}
- if (!createdTables.contains(sti.getBaseName())) {
+ if (!this.createdTables.contains(sti.getBaseName())) {
// on vérifie qu'elle n'existe pas
try {
- ResultSet rs = st.executeQuery("SELECT 1 FROM " + sti.getBaseName());
- createdTables.add(sti.getBaseName());
+ final ResultSet rs = st.executeQuery("SELECT 1 FROM " + sti.getBaseName());
+ this.createdTables.add(sti.getBaseName());
return;
- } catch (SQLException testEx) {
+ } catch (final SQLException testEx) {
if (sti.getSqls().size() == 0) {
try {
st.executeUpdate(sti.getScript());
- } catch (SQLException sqlEx) {
- logger.error("createTable: " + sti.getScript(), sqlEx);
+ } catch (final SQLException sqlEx) {
+ OracleDataLayer.logger.error("createTable: " + sti.getScript(), sqlEx);
throw sqlEx;
}
} else {
- for (TSql sql : sti.getSqls()) {
+ for (final TSql sql : sti.getSqls()) {
try {
st.executeQuery(sql.getScript(sti.getBaseName()));
- } catch (SQLException sqlEx) {
+ } catch (final SQLException sqlEx) {
if (sql.isFailOnError()) {
- logger.error(sql.getScript(sti.getBaseName()), sqlEx);
+ OracleDataLayer.logger.error(sql.getScript(sti.getBaseName()), sqlEx);
throw sqlEx;
- } else
- logger.warn(sql.getScript(sti.getBaseName()), sqlEx);
+ } else {
+ OracleDataLayer.logger.warn(sql.getScript(sti.getBaseName()), sqlEx);
+ }
}
}
}
} else {
st.executeUpdate("INSERT INTO TABLES_VERSIONS (TABLE_NAME,VERSION) VALUES ('" + sti.getBaseName() + "'," + sti.getVersion() + ")");
}
- createdTables.add(sti.getBaseName());
+ this.createdTables.add(sti.getBaseName());
}
}
}
* @return <tt>true</tt> is this <tt>docName</tt> has been imported
* @throws SQLException
*/
- private boolean documentExists(TDocument pc, Pair codeBudget, Pair collectivite, String docName, Connection con) throws SQLException {
+ private boolean documentExists(final TDocument pc, final Pair codeBudget, final Pair collectivite, final String docName, final Connection con) throws SQLException {
PreparedStatement ps = null;
boolean bRet = false;
try {
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("select 1 from ").append(pc.getListBcTable().getBaseName()).append(" where " + pc.getInitialDocNameColname() + "=? AND " + pc.getBudgetCodeColname() + "=? AND " + pc.getCollectiviteCodeColname() + "=?");
ps = con.prepareStatement(sb.toString());
ps.setString(1, docName);
ps.setString(2, codeBudget.key);
ps.setString(3, collectivite.key);
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
bRet = rs.next();
rs.close();
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
}
* @return
* @throws SQLException
*/
- protected boolean doesRepositoryExist(TDocument pc, String collectivite, Connection con, String idNomenclature) throws SQLException {
+ protected boolean doesRepositoryExist(final TDocument pc, final String collectivite, final Connection con, final String idNomenclature) throws SQLException {
boolean bRet = false;
if (pc.getRepositoryTable() == null) {
return false;
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
sb.append("SELECT 1 FROM ").append(pc.getRepositoryTable().getBaseName()).append(" WHERE " + pc.getCollectiviteCodeColname() + "=? AND ID");
if (idNomenclature != null) {
sb.append("=?");
ps.setString(2, idNomenclature);
}
- ResultSet rs = ps.executeQuery();
+ final ResultSet rs = ps.executeQuery();
bRet = rs.next();
rs.close();
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
}
return bRet;
}
- protected String transformXPathToSql(ElementModel elementModel, Pair collectivite, Pair budget, String xPath, Vector<CritereModel> models, XemeliosUser user) throws DataConfigurationException {
- EtatModel etatModel = elementModel.getParent();
- DocumentModel documentModel = etatModel.getParent();
+ protected String transformXPathToSql(final ElementModel elementModel, final Pair collectivite, final Pair budget, final String xPath, final Vector<CritereModel> models, final XemeliosUser user) throws DataConfigurationException {
+ final EtatModel etatModel = elementModel.getParent();
+ final DocumentModel documentModel = etatModel.getParent();
- TDocument pc = getPersistenceConfig(documentModel, user).getLayer(getLayerName()).getDocument(documentModel.getId());
- TEtat sec = pc.getEtat(etatModel.getId());
+ final TDocument pc = this.getPersistenceConfig(documentModel, user).getLayer(this.getLayerName()).getDocument(documentModel.getId());
+ final TEtat sec = pc.getEtat(etatModel.getId());
// ensure xPath expr starts with element path
if (!xPath.substring(0, elementModel.getPath().getPath().length()).equals(elementModel.getPath().getPath())) {
throw new DataConfigurationException("XPath: " + xPath + " does not start with element[" + elementModel.getId() + "] path");
}
- StringBuilder sb = new StringBuilder();
+ final StringBuilder sb = new StringBuilder();
// splitts by OR clause
- ArrayList<CritereModel> part = new ArrayList<CritereModel>();
- boolean firstPart = true;
+ final ArrayList<CritereModel> part = new ArrayList<CritereModel>();
+ final boolean firstPart = true;
if (models != null) {
- for (CritereModel cm : models) {
- TCriteria ci = sec.getCriteria(cm.getId());
+ for (final CritereModel cm : models) {
+ final TCriteria ci = sec.getCriteria(cm.getId());
if (ci == null) {
throw new DataConfigurationException("no criteria persistence info found for " + cm.getId());
}
part.add(cm);
}
}
- appendRequest(pc, part, sb, sec, collectivite, budget, firstPart);
+ this.appendRequest(pc, part, sb, sec, collectivite, budget, firstPart);
return sb.toString();
}
- protected void appendRequest(TDocument pc, ArrayList<CritereModel> criterias, StringBuilder sb, TEtat sec, Pair collectivite, Pair budget, boolean firstPart) throws DataConfigurationException {
- TTable mainTable = sec.getMaintable();
+ protected void appendRequest(final TDocument pc, final ArrayList<CritereModel> criterias, final StringBuilder sb, final TEtat sec, final Pair collectivite, final Pair budget, final boolean firstPart) throws DataConfigurationException {
+ final TTable mainTable = sec.getMaintable();
- String mainTableName = mainTable.getBaseName().trim();
- String collectiviteCodeColName = pc.getCollectiviteCodeColname();
- String budgetCodeColname = pc.getBudgetCodeColname();
- String mainTableDocIdCol = mainTableName + ".DOC_ID";
- String mainTableColCol = mainTableName + "." + collectiviteCodeColName;
- String mainTableBudCol = mainTableName + "." + budgetCodeColname;
+ final String mainTableName = mainTable.getBaseName().trim();
+ final String collectiviteCodeColName = pc.getCollectiviteCodeColname();
+ final String budgetCodeColname = pc.getBudgetCodeColname();
+ final String mainTableDocIdCol = mainTableName + ".DOC_ID";
+ final String mainTableColCol = mainTableName + "." + collectiviteCodeColName;
+ final String mainTableBudCol = mainTableName + "." + budgetCodeColname;
- HashSet<String> usedTable = new HashSet<String>();
- StringBuilder fromClause = new StringBuilder(mainTableName);
- StringBuilder whereClause = new StringBuilder();
+ final HashSet<String> usedTable = new HashSet<String>();
+ final StringBuilder fromClause = new StringBuilder(mainTableName);
+ final StringBuilder whereClause = new StringBuilder();
- //filtre collectivite/budget
+ // filtre collectivite/budget
whereClause.append(" WHERE (").append(mainTableColCol).append(" = '").append(StringEscapeUtils.escapeSql(collectivite.key)).append("'");
whereClause.append(" AND ").append(mainTableBudCol).append(" = '").append(StringEscapeUtils.escapeSql(budget.key)).append("'");
-
+
usedTable.add(mainTableName);
- String lastConnector = "&&";
-
- for (CritereModel cm : criterias) {
- TCriteria criteria = (TCriteria) cm.getAdditionnalData();
+ final String lastConnector = "&&";
+
+ for (final CritereModel cm : criterias) {
+ final TCriteria criteria = (TCriteria) cm.getAdditionnalData();
if (criteria.getSqlIndexId() == null) {
- logger.warn("SQL index not found for criteria : " + criteria.getId());
+ OracleDataLayer.logger.warn("SQL index not found for criteria : " + criteria.getId());
} else {
- TSqlIndex sqlIndex = sec.getSqlIndexById(criteria.getSqlIndexId());
- TTable tableIndex = sec.getIndexTable(sqlIndex.getTableId());
- String idxTableName = tableIndex.getBaseName().trim();
- String connector = (StringUtils.isEmpty(cm.getProperty("AND_OR")) ? "&&" : cm.getProperty("AND_OR"));
+ final TSqlIndex sqlIndex = sec.getSqlIndexById(criteria.getSqlIndexId());
+ final TTable tableIndex = sec.getIndexTable(sqlIndex.getTableId());
+ final String idxTableName = tableIndex.getBaseName().trim();
+ final String connector = (StringUtils.isEmpty(cm.getProperty("AND_OR")) ? "&&" : cm.getProperty("AND_OR"));
- String whereCond = criteria.getSubstitutedWhereClause(cm, getEvaluatorsFunctions(), applicationProperties);
+ String whereCond = criteria.getSubstitutedWhereClause(cm, this.getEvaluatorsFunctions(), this.applicationProperties);
whereCond = whereCond.replaceAll("\\$\\{table\\}", idxTableName);
whereCond = whereCond.replaceAll("\\$\\{column\\}", sqlIndex.getColumn());
whereCond = whereCond.trim();
- //on ajoute la condition
+ // on ajoute la condition
if (!StringUtils.isEmpty(whereCond)) {
- if(!connector.equals(lastConnector)){
+ if (!connector.equals(lastConnector)) {
whereClause.append(")");
}
-
+
whereClause.append("||".equals(connector) ? " OR " : " AND ");
-
- if(!connector.equals(lastConnector)){
+
+ if (!connector.equals(lastConnector)) {
whereClause.append("(");
}
-
+
whereClause.append(whereCond);
- //on ajoute les tables manquante dans le FROM
+ // on ajoute les tables manquante dans le FROM
if (!usedTable.contains(idxTableName)) {
- String idxDocIdCol = idxTableName + ".DOC_ID";
- String idxColCol = idxTableName + " ." + collectiviteCodeColName;
- String idxBudCol = idxTableName + " ." + budgetCodeColname;
+ final String idxDocIdCol = idxTableName + ".DOC_ID";
+ final String idxColCol = idxTableName + " ." + collectiviteCodeColName;
+ final String idxBudCol = idxTableName + " ." + budgetCodeColname;
- String fromLf = " LEFT JOIN " + idxTableName + " ON " + idxDocIdCol + "=" + mainTableDocIdCol + " AND " + idxColCol + "=" + mainTableColCol + " AND " + idxBudCol + "=" + mainTableBudCol;
+ final String fromLf = " LEFT JOIN " + idxTableName + " ON " + idxDocIdCol + "=" + mainTableDocIdCol + " AND " + idxColCol + "=" + mainTableColCol + " AND " + idxBudCol + "=" + mainTableBudCol;
fromClause.append(fromLf);
}
}
}
-
- if(lastConnector != null){
+
+ if (lastConnector != null) {
whereClause.append(")");
}
-
- whereClause.append(" ").append(WHERE_REPLACEMENT);
-
- fromClause.append(" ").append(FROM_REPLACEMENT);
-
+
+ whereClause.append(" ").append(OracleDataLayer.WHERE_REPLACEMENT);
+
+ fromClause.append(" ").append(OracleDataLayer.FROM_REPLACEMENT);
+
sb.setLength(0);
- sb.append("SELECT ").append(mainTableDocIdCol).append(" FROM ").append(fromClause.toString()).append(" ").append(whereClause.toString()).append(" ").append(ORDER_BY_REPLACEMENT);
+ sb.append("SELECT ").append(mainTableDocIdCol).append(" FROM ").append(fromClause.toString()).append(" ").append(whereClause.toString()).append(" ").append(OracleDataLayer.ORDER_BY_REPLACEMENT);
}
private class IndexerHandler extends DefaultHandler {
private TDocument pc = null;
private Stack<QName> stack = null;
private String key1 = null, key2 = null, key3 = null, key4 = null, key5 = null, key6 = null, key7 = null, key8 = null, key9 = null, key10 = null;
- private String pathToResetKey1 = null, pathToResetKey2 = null, pathToResetKey3 = null, pathToResetKey4 = null, pathToResetKey5 = null, pathToResetKey6 = null, pathToResetKey7 = null, pathToResetKey8 = null, pathToResetKey9 = null,
- pathToResetKey10 = null;
+ private String pathToResetKey1 = null, pathToResetKey2 = null, pathToResetKey3 = null, pathToResetKey4 = null, pathToResetKey5 = null, pathToResetKey6 = null, pathToResetKey7 = null, pathToResetKey8 = null, pathToResetKey9 = null, pathToResetKey10 = null;
private String collectivite = null, budget = null, docId = null;
private SQLException sqlEx = null;
private long indexDuration = 0L;
private String archiveName = null;
public long getIndexDuration() {
- return indexDuration;
+ return this.indexDuration;
}
public void reset() {
- indexDuration = 0L;
- if (cachedData != null) {
- cachedData.clear();
+ this.indexDuration = 0L;
+ if (this.cachedData != null) {
+ this.cachedData.clear();
}
- if (stack != null) {
- stack.clear();
+ if (this.stack != null) {
+ this.stack.clear();
}
// sec = null;
- key1 = null;
- key2 = null;
- key3 = null;
- key4 = null;
- key5 = null;
- key6 = null;
- key7 = null;
- key8 = null;
- key9 = null;
- key10 = null;
- pathToResetKey1 = null;
- pathToResetKey2 = null;
- pathToResetKey3 = null;
- pathToResetKey4 = null;
- pathToResetKey5 = null;
- pathToResetKey6 = null;
- pathToResetKey7 = null;
- pathToResetKey8 = null;
- pathToResetKey9 = null;
- pathToResetKey10 = null;
- }
-
- public IndexerHandler(TEtat sec, String codeBudget, String codeCollectivite, String elementName, Connection con, NamespaceContext nsCtx, String originFileName, String archiveName) throws SQLException {
+ this.key1 = null;
+ this.key2 = null;
+ this.key3 = null;
+ this.key4 = null;
+ this.key5 = null;
+ this.key6 = null;
+ this.key7 = null;
+ this.key8 = null;
+ this.key9 = null;
+ this.key10 = null;
+ this.pathToResetKey1 = null;
+ this.pathToResetKey2 = null;
+ this.pathToResetKey3 = null;
+ this.pathToResetKey4 = null;
+ this.pathToResetKey5 = null;
+ this.pathToResetKey6 = null;
+ this.pathToResetKey7 = null;
+ this.pathToResetKey8 = null;
+ this.pathToResetKey9 = null;
+ this.pathToResetKey10 = null;
+ }
+
+ public IndexerHandler(final TEtat sec, final String codeBudget, final String codeCollectivite, final String elementName, final Connection con, final NamespaceContext nsCtx, final String originFileName, final String archiveName) throws SQLException {
super();
this.sec = sec;
this.pc = sec.getParent();
- stack = new Stack<QName>();
+ this.stack = new Stack<QName>();
this.collectivite = codeCollectivite;
this.budget = codeBudget;
this.docId = elementName;
- cachedData = new Hashtable<TSqlIndex, Object>();
+ this.cachedData = new Hashtable<TSqlIndex, Object>();
this.con = con;
- warnings = new StringBuffer();
- datas = new Stack<StringBuffer>();
+ this.warnings = new StringBuffer();
+ this.datas = new Stack<StringBuffer>();
this.nsCtx = nsCtx;
if (nsCtx == null) {
throw new IllegalArgumentException("nsCtx can not be null)");
}
@Override
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- QName qname = XmlUtils.getQName(uri, localName, qName);
- stack.push(qname);
- datas.push(new StringBuffer());
- String pathTag = XmlUtils.getPath(stack, nsCtx);
+ public void startElement(final String uri, final String localName, final String qName, final Attributes attributes) throws SAXException {
+ final QName qname = XmlUtils.getQName(uri, localName, qName);
+ this.stack.push(qname);
+ this.datas.push(new StringBuffer());
+ final String pathTag = XmlUtils.getPath(this.stack, this.nsCtx);
for (int i = 0; i < attributes.getLength(); i++) {
- String prefix = nsCtx.getPrefix(attributes.getURI(i));
- StringBuffer sb = new StringBuffer();
+ final String prefix = this.nsCtx.getPrefix(attributes.getURI(i));
+ final StringBuffer sb = new StringBuffer();
sb.append(pathTag).append("/@");
- if (prefix != null && prefix.length() > 0) {
+ if ((prefix != null) && (prefix.length() > 0)) {
sb.append(prefix).append(":");
}
sb.append(attributes.getLocalName(i));
- String fullPath = sb.toString();
- if (sec.getKey1() != null && sec.getKey1().getPathes().contains(fullPath)) {
- key1 = attributes.getValue(i);
- pathToResetKey1 = pathTag;
+ final String fullPath = sb.toString();
+ if ((this.sec.getKey1() != null) && this.sec.getKey1().getPathes().contains(fullPath)) {
+ this.key1 = attributes.getValue(i);
+ this.pathToResetKey1 = pathTag;
}
- if (sec.getKey2() != null && sec.getKey2().getPathes().contains(fullPath)) {
- key2 = attributes.getValue(i);
- pathToResetKey2 = pathTag;
+ if ((this.sec.getKey2() != null) && this.sec.getKey2().getPathes().contains(fullPath)) {
+ this.key2 = attributes.getValue(i);
+ this.pathToResetKey2 = pathTag;
}
- if (sec.getKey3() != null && sec.getKey3().getPathes().contains(fullPath)) {
- key3 = attributes.getValue(i);
- pathToResetKey3 = pathTag;
+ if ((this.sec.getKey3() != null) && this.sec.getKey3().getPathes().contains(fullPath)) {
+ this.key3 = attributes.getValue(i);
+ this.pathToResetKey3 = pathTag;
}
- if (sec.getKey4() != null && sec.getKey4().getPathes().contains(fullPath)) {
- key4 = attributes.getValue(i);
- pathToResetKey4 = pathTag;
+ if ((this.sec.getKey4() != null) && this.sec.getKey4().getPathes().contains(fullPath)) {
+ this.key4 = attributes.getValue(i);
+ this.pathToResetKey4 = pathTag;
}
- if (sec.getKey5() != null && sec.getKey5().getPathes().contains(fullPath)) {
- key5 = attributes.getValue(i);
- pathToResetKey5 = pathTag;
+ if ((this.sec.getKey5() != null) && this.sec.getKey5().getPathes().contains(fullPath)) {
+ this.key5 = attributes.getValue(i);
+ this.pathToResetKey5 = pathTag;
}
- if (sec.getKey6() != null && sec.getKey6().getPathes().contains(fullPath)) {
- key6 = attributes.getValue(i);
- pathToResetKey6 = pathTag;
+ if ((this.sec.getKey6() != null) && this.sec.getKey6().getPathes().contains(fullPath)) {
+ this.key6 = attributes.getValue(i);
+ this.pathToResetKey6 = pathTag;
}
- if (sec.getKey7() != null && sec.getKey7().getPathes().contains(fullPath)) {
- key7 = attributes.getValue(i);
- pathToResetKey7 = pathTag;
+ if ((this.sec.getKey7() != null) && this.sec.getKey7().getPathes().contains(fullPath)) {
+ this.key7 = attributes.getValue(i);
+ this.pathToResetKey7 = pathTag;
}
- if (sec.getKey8() != null && sec.getKey8().getPathes().contains(fullPath)) {
- key8 = attributes.getValue(i);
- pathToResetKey8 = pathTag;
+ if ((this.sec.getKey8() != null) && this.sec.getKey8().getPathes().contains(fullPath)) {
+ this.key8 = attributes.getValue(i);
+ this.pathToResetKey8 = pathTag;
}
- if (sec.getKey9() != null && sec.getKey9().getPathes().contains(fullPath)) {
- key9 = attributes.getValue(i);
- pathToResetKey9 = pathTag;
+ if ((this.sec.getKey9() != null) && this.sec.getKey9().getPathes().contains(fullPath)) {
+ this.key9 = attributes.getValue(i);
+ this.pathToResetKey9 = pathTag;
}
- if (sec.getKey10() != null && sec.getKey10().getPathes().contains(fullPath)) {
- key10 = attributes.getValue(i);
- pathToResetKey10 = pathTag;
+ if ((this.sec.getKey10() != null) && this.sec.getKey10().getPathes().contains(fullPath)) {
+ this.key10 = attributes.getValue(i);
+ this.pathToResetKey10 = pathTag;
}
- ArrayList<TSqlIndex> indexList = sec.getAllIndexesByPath(fullPath);
+ final ArrayList<TSqlIndex> indexList = this.sec.getAllIndexesByPath(fullPath);
if (indexList != null) {
- for (TSqlIndex si : indexList) {
+ for (final TSqlIndex si : indexList) {
// on ignore les index dont @generate='false'
if (!si.isGenerate()) {
continue;
}
- String sValue = attributes.getValue(i);
+ final String sValue = attributes.getValue(i);
Object value = null;
if (TPersistenceConfig.DATATYPE_INTEGER.equals(si.getDatatype())) {
try {
value = Integer.valueOf(sValue.trim());
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_DECIMAL.equals(si.getDatatype())) {
try {
value = new BigDecimal(sValue.trim());
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_FLOAT.equals(si.getDatatype())) {
try {
value = new Float(Float.parseFloat(sValue.trim()));
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_DATE.equals(si.getDatatype())) {
try {
value = si.getDateValue(sValue.trim());
- } catch (java.text.ParseException ex) {
- logger.warn(ex.getMessage());
+ } catch (final java.text.ParseException ex) {
+ OracleDataLayer.logger.warn(ex.getMessage());
}
} else if (TPersistenceConfig.DATATYPE_STRING.equals(si.getDatatype())) {
value = si.getFormattedStringValue(sValue);
value = si.getBooleanValue(sValue.trim());
} else {
value = sValue;
- logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
+ OracleDataLayer.logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
}
if (value != null) {
- cachedData.put(si, value);
+ this.cachedData.put(si, value);
}
}
}
}
- String fullPath = pathTag + "/name()";
- ArrayList<TSqlIndex> indexList = sec.getAllIndexesByPath(fullPath);
- for (TSqlIndex si : indexList) {
+ final String fullPath = pathTag + "/name()";
+ final ArrayList<TSqlIndex> indexList = this.sec.getAllIndexesByPath(fullPath);
+ for (final TSqlIndex si : indexList) {
if (si != null) {
if (!si.isGenerate()) {
continue;
}
- String sValue = localName;
+ final String sValue = localName;
Object value = null;
if (TPersistenceConfig.DATATYPE_INTEGER.equals(si.getDatatype())) {
try {
value = Integer.valueOf(sValue.trim());
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_DECIMAL.equals(si.getDatatype())) {
try {
value = new BigDecimal(sValue.trim());
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_FLOAT.equals(si.getDatatype())) {
try {
value = new Float(Float.parseFloat(sValue.trim()));
- } catch (NumberFormatException ex) {
+ } catch (final NumberFormatException ex) {
if (sValue != null) {
- logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
+ OracleDataLayer.logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
}
}
} else if (TPersistenceConfig.DATATYPE_DATE.equals(si.getDatatype())) {
try {
value = si.getDateValue(sValue.trim());
- } catch (java.text.ParseException ex) {
- logger.warn(ex.getMessage());
+ } catch (final java.text.ParseException ex) {
+ OracleDataLayer.logger.warn(ex.getMessage());
}
} else if (TPersistenceConfig.DATATYPE_STRING.equals(si.getDatatype())) {
value = si.getFormattedStringValue(sValue);
} else if (TPersistenceConfig.DATATYPE_BOOLEAN.equals(si.getDatatype())) {
- String sTmp = sValue.toString();
+ final String sTmp = sValue.toString();
if ("1".equals(si.getBooleanValue(sValue))) {
value = Boolean.TRUE;
} else {
}
} else {
value = sValue;
- logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
+ OracleDataLayer.logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
}
if (value != null) {
- cachedData.put(si, value);
+ this.cachedData.put(si, value);
}
}
}
}
- protected void closePathToReset(String pathTag) throws SAXException {
- if (pathTag.equals(pathToResetKey10)) {
- pathToResetKey10 = null;
+ protected void closePathToReset(final String pathTag) throws SAXException {
+ if (pathTag.equals(this.pathToResetKey10)) {
+ this.pathToResetKey10 = null;
try {
- writeIndexesOnKey10();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey10();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
ex.printStackTrace();
throw new SAXException("SQLException occurs. See nested exception for details)", ex);
- } catch (DataConfigurationException dcEx) {
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key10 = null;
- } else if (pathTag.equals(pathToResetKey9)) {
- pathToResetKey9 = null;
+ this.key10 = null;
+ } else if (pathTag.equals(this.pathToResetKey9)) {
+ this.pathToResetKey9 = null;
try {
- writeIndexesOnKey9();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey9();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
ex.printStackTrace();
throw new SAXException("SQLException occurs. See nested exception for details)", ex);
- } catch (DataConfigurationException dcEx) {
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key9 = null;
- } else if (pathTag.equals(pathToResetKey8)) {
- pathToResetKey8 = null;
+ this.key9 = null;
+ } else if (pathTag.equals(this.pathToResetKey8)) {
+ this.pathToResetKey8 = null;
try {
- writeIndexesOnKey8();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey8();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
ex.printStackTrace();
throw new SAXException("SQLException occurs. See nested exception for details)", ex);
- } catch (DataConfigurationException dcEx) {
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key8 = null;
- } else if (pathTag.equals(pathToResetKey7)) {
- pathToResetKey7 = null;
+ this.key8 = null;
+ } else if (pathTag.equals(this.pathToResetKey7)) {
+ this.pathToResetKey7 = null;
try {
- writeIndexesOnKey7();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey7();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key7 = null;
- } else if (pathTag.equals(pathToResetKey6)) {
- pathToResetKey6 = null;
+ this.key7 = null;
+ } else if (pathTag.equals(this.pathToResetKey6)) {
+ this.pathToResetKey6 = null;
try {
- writeIndexesOnKey6();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey6();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key6 = null;
- } else if (pathTag.equals(pathToResetKey5)) {
- pathToResetKey5 = null;
+ this.key6 = null;
+ } else if (pathTag.equals(this.pathToResetKey5)) {
+ this.pathToResetKey5 = null;
try {
- writeIndexesOnKey5();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey5();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key5 = null;
- } else if (pathTag.equals(pathToResetKey4)) {
- pathToResetKey4 = null;
+ this.key5 = null;
+ } else if (pathTag.equals(this.pathToResetKey4)) {
+ this.pathToResetKey4 = null;
try {
- writeIndexesOnKey4();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey4();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key4 = null;
- } else if (pathTag.equals(pathToResetKey3)) {
- pathToResetKey3 = null;
+ this.key4 = null;
+ } else if (pathTag.equals(this.pathToResetKey3)) {
+ this.pathToResetKey3 = null;
try {
- writeIndexesOnKey3();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey3();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key3 = null;
- } else if (pathTag.equals(pathToResetKey2)) {
- pathToResetKey2 = null;
+ this.key3 = null;
+ } else if (pathTag.equals(this.pathToResetKey2)) {
+ this.pathToResetKey2 = null;
try {
- writeIndexesOnKey2();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey2();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key2 = null;
- } else if (pathTag.equals(pathToResetKey1)) {
- pathToResetKey1 = null;
+ this.key2 = null;
+ } else if (pathTag.equals(this.pathToResetKey1)) {
+ this.pathToResetKey1 = null;
try {
- writeIndexesOnKey1();
- } catch (SQLException ex) {
+ this.writeIndexesOnKey1();
+ } catch (final SQLException ex) {
this.sqlEx = ex;
- sqlEx.printStackTrace();
- throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx);
- } catch (DataConfigurationException dcEx) {
+ this.sqlEx.printStackTrace();
+ throw new SAXException("SQLException occurs. See nested exception for details)", this.sqlEx);
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
- throw new SAXException("DataConfigurationException occurs. See nested exception for details)", sqlEx);
+ throw new SAXException("DataConfigurationException occurs. See nested exception for details)", this.sqlEx);
}
- key1 = null;
+ this.key1 = null;
}
}
@Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- String pathTag = XmlUtils.getPath(stack, nsCtx);
- closePathToReset(pathTag);
- String fullPath = pathTag + "/text()";
- ArrayList<TSqlIndex> indexList = sec.getAllIndexesByPath(fullPath);
- for (TSqlIndex si : indexList) {
+ public void endElement(final String uri, final String localName, final String qName) throws SAXException {
+ final String pathTag = XmlUtils.getPath(this.stack, this.nsCtx);
+ this.closePathToReset(pathTag);
+ final String fullPath = pathTag + "/text()";
+ final ArrayList<TSqlIndex> indexList = this.sec.getAllIndexesByPath(fullPath);
+ for (final TSqlIndex si : indexList) {
if (si != null) {
if (!si.isGenerate()) {
continue;
}
- String sValue = datas.peek().toString();
+ final String sValue = this.datas.peek().toString();
Object value = null;
if (TPersistenceConfig.DATATYPE_INTEGER.equals(si.getDatatype())) {
try {
value = Integer.valueOf(sValue.trim());
- } catch (NumberFormatException ex) {
- logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
+ } catch (final NumberFormatException ex) {
+ OracleDataLayer.logger.warn(sValue + " is not an integer - " + si.getTableId() + "." + si.getColumn());
}
} else if (TPersistenceConfig.DATATYPE_DECIMAL.equals(si.getDatatype())) {
try {
value = new BigDecimal(sValue.trim());
- } catch (NumberFormatException ex) {
- logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
+ } catch (final NumberFormatException ex) {
+ OracleDataLayer.logger.warn(sValue + " is not a decimal - " + si.getTableId() + "." + si.getColumn());
}
} else if (TPersistenceConfig.DATATYPE_FLOAT.equals(si.getDatatype())) {
try {
value = new Float(Float.parseFloat(sValue.trim()));
- } catch (NumberFormatException ex) {
- logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
+ } catch (final NumberFormatException ex) {
+ OracleDataLayer.logger.warn(sValue + " is not a float - " + si.getTableId() + "." + si.getColumn());
}
} else if (TPersistenceConfig.DATATYPE_DATE.equals(si.getDatatype())) {
try {
value = si.getDateValue(sValue.trim());
- } catch (java.text.ParseException ex) {
- logger.warn(ex.getMessage());
+ } catch (final java.text.ParseException ex) {
+ OracleDataLayer.logger.warn(ex.getMessage());
}
} else if (TPersistenceConfig.DATATYPE_STRING.equals(si.getDatatype())) {
value = si.getFormattedStringValue(sValue);
} else if (TPersistenceConfig.DATATYPE_BOOLEAN.equals(si.getDatatype())) {
- String sTmp = sValue.toString();
+ final String sTmp = sValue.toString();
if ("1".equals(si.getBooleanValue(sValue))) {
value = Boolean.TRUE;
} else {
}
} else {
value = sValue;
- logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
+ OracleDataLayer.logger.error("unknown datatype for index " + si.getId() + ": " + si.getDatatype());
}
if (value != null) {
- cachedData.put(si, value);
+ this.cachedData.put(si, value);
}
}
}
- closePathToReset(fullPath);
- datas.pop();
- stack.pop();
+ this.closePathToReset(fullPath);
+ this.datas.pop();
+ this.stack.pop();
}
@Override
public void endDocument() throws SAXException {
try {
- writeElementBasedIndexes();
- cachedData.clear();
- } catch (SQLException sqlEx2) {
+ this.writeElementBasedIndexes();
+ this.cachedData.clear();
+ } catch (final SQLException sqlEx2) {
sqlEx2.printStackTrace();
this.sqlEx = sqlEx2;
throw new SAXException("SQLException occurs. See nested exception for details)", sqlEx2);
- } catch (DataConfigurationException dcEx) {
+ } catch (final DataConfigurationException dcEx) {
dcEx.printStackTrace();
throw new SAXException("DataConfiguration occurs. See nested exception for details", dcEx);
}
protected void writeIndexesOnKey1() throws SQLException, DataConfigurationException {
try {
- writeIndexesOnKey("key1");
- } catch (SQLException sqlEx2) {
- logger.error(sqlEx2);
+ this.writeIndexesOnKey("key1");
+ } catch (final SQLException sqlEx2) {
+ OracleDataLayer.logger.error(sqlEx2);
throw sqlEx2;
- } catch (DataConfigurationException dcEx) {
- logger.error(dcEx);
+ } catch (final DataConfigurationException dcEx) {
+ OracleDataLayer.logger.error(dcEx);
throw dcEx;
}
}
protected void writeIndexesOnKey2() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key2");
+ this.writeIndexesOnKey("key2");
}
protected void writeIndexesOnKey3() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key3");
+ this.writeIndexesOnKey("key3");
}
protected void writeIndexesOnKey4() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key4");
+ this.writeIndexesOnKey("key4");
}
protected void writeIndexesOnKey5() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key5");
+ this.writeIndexesOnKey("key5");
}
protected void writeIndexesOnKey6() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key6");
+ this.writeIndexesOnKey("key6");
}
protected void writeIndexesOnKey7() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key7");
+ this.writeIndexesOnKey("key7");
}
protected void writeIndexesOnKey8() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key8");
+ this.writeIndexesOnKey("key8");
}
protected void writeIndexesOnKey9() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key9");
+ this.writeIndexesOnKey("key9");
}
protected void writeIndexesOnKey10() throws SQLException, DataConfigurationException {
- writeIndexesOnKey("key10");
+ this.writeIndexesOnKey("key10");
}
- protected void writeIndexesOnKey(String keyName) throws SQLException, DataConfigurationException {
+ protected void writeIndexesOnKey(final String keyName) throws SQLException, DataConfigurationException {
// First, try to get index table
TTable elementTable = null;
- for (TTable ti : sec.getIndexTables()) {
+ for (final TTable ti : this.sec.getIndexTables()) {
if (keyName.equals(ti.getBasedOn())) {
elementTable = ti;
break;
throw new DataConfigurationException("No table to store " + keyName + " indexes was found !");
}
//
- StringBuilder sql = new StringBuilder();
- sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + pc.getCollectiviteCodeColname() + "," + pc.getBudgetCodeColname() + ",DOC_ID," + pc.getInitialDocNameColname() + ", " + pc.getArchiveNameColname() + ",");
- Vector<Object> valuesToWrite = new Vector<Object>();
- Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
- for (Enumeration<TSqlIndex> enumer = cachedData.keys(); enumer.hasMoreElements();) {
- TSqlIndex index = enumer.nextElement();
- String tableId = index.getTableId();
- TTable sti = sec.getIndexTable(tableId);
+ final StringBuilder sql = new StringBuilder();
+ sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + ", " + this.pc.getArchiveNameColname() + ",");
+ final Vector<Object> valuesToWrite = new Vector<Object>();
+ final Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
+ for (final Enumeration<TSqlIndex> enumer = this.cachedData.keys(); enumer.hasMoreElements();) {
+ final TSqlIndex index = enumer.nextElement();
+ final String tableId = index.getTableId();
+ final TTable sti = this.sec.getIndexTable(tableId);
if (sti == elementTable) {
// we are on the element-based table
sql.append(index.getColumn()).append(",");
indexesToWrite.add(index);
- valuesToWrite.add(cachedData.get(index));
- if (keyName.equals(index.getResetOn()) || index.getResetOn() == null) {
- cachedData.remove(index);
+ valuesToWrite.add(this.cachedData.get(index));
+ if (keyName.equals(index.getResetOn()) || (index.getResetOn() == null)) {
+ this.cachedData.remove(index);
}
}
}
sql.append(")");
PreparedStatement ps = null;
try {
- ps = con.prepareStatement(sql.toString());
- ps.setString(1, collectivite);
- ps.setString(2, budget);
- ps.setString(3, docId);
- ps.setString(4, originFileName);
- if (archiveName == null) {
+ ps = this.con.prepareStatement(sql.toString());
+ ps.setString(1, this.collectivite);
+ ps.setString(2, this.budget);
+ ps.setString(3, this.docId);
+ ps.setString(4, this.originFileName);
+ if (this.archiveName == null) {
ps.setNull(5, Types.VARCHAR);
} else {
- ps.setString(5, archiveName);
+ ps.setString(5, this.archiveName);
}
final int base = 6;
for (int i = 0; i < valuesToWrite.size(); i++) {
- TSqlIndex index = indexesToWrite.elementAt(i);
- Object value = valuesToWrite.elementAt(i);
+ final TSqlIndex index = indexesToWrite.elementAt(i);
+ final Object value = valuesToWrite.elementAt(i);
if (TPersistenceConfig.DATATYPE_DECIMAL.equals(index.getDatatype())) {
if (value instanceof BigDecimal) {
ps.setBigDecimal(i + base, (BigDecimal) value);
- logger.trace("BigDecimal OK");
+ OracleDataLayer.logger.trace("BigDecimal OK");
} else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_DATE.equals(index.getDatatype())) {
if (value instanceof Date) {
ps.setDate(i + base, (Date) value);
- logger.trace("Date OK");
+ OracleDataLayer.logger.trace("Date OK");
} else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_FLOAT.equals(index.getDatatype())) {
if (value instanceof Float) {
ps.setFloat(i + base, ((Float) value).floatValue());
- logger.trace("Float OK");
+ OracleDataLayer.logger.trace("Float OK");
} else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_INTEGER.equals(index.getDatatype())) {
if (value instanceof Integer) {
ps.setInt(i + base, ((Integer) value).intValue());
- logger.trace("Integer OK");
+ OracleDataLayer.logger.trace("Integer OK");
} else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_BOOLEAN.equals(index.getDatatype())) {
ps.setInt(i + base, ("true".equals(value) || "1".equals(value)) ? 1 : 0);
} else {
ps.setString(i + base, value.toString());
}
- if (keyName.equals(index.getResetOn()) || index.getResetOn() == null) {
- cachedData.remove(index);
+ if (keyName.equals(index.getResetOn()) || (index.getResetOn() == null)) {
+ this.cachedData.remove(index);
}
}
ps.executeUpdate();
SQLWarning warn = ps.getWarnings();
while (warn != null) {
- warnings.append(warn.getMessage()).append("\n");
+ this.warnings.append(warn.getMessage()).append("\n");
warn = warn.getNextWarning();
}
- } catch (SQLException sqlEx2) {
- StringBuilder sb = new StringBuilder();
+ } catch (final SQLException sqlEx2) {
+ final StringBuilder sb = new StringBuilder();
sb.append("1: inserting into ").append(elementTable.getBaseName()).append(": ").append(sqlEx2.getMessage()).append("\n");
for (int i = 0; i < valuesToWrite.size(); i++) {
- TSqlIndex index = indexesToWrite.elementAt(i);
- Object value = valuesToWrite.elementAt(i);
+ final TSqlIndex index = indexesToWrite.elementAt(i);
+ final Object value = valuesToWrite.elementAt(i);
sb.append("\t").append(index.getColumn()).append(" -> ").append(value != null ? value.toString() : "<null>").append(" (").append(value != null ? value.getClass().getName() : "--").append(")\n");
}
- logger.error(sb.toString());
+ OracleDataLayer.logger.error(sb.toString());
// sqlEx2.printStackTrace();
} finally {
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
}
}
valuesToWrite.clear();
indexesToWrite.clear();
- for (Enumeration<TSqlIndex> enumer = cachedData.keys(); enumer.hasMoreElements();) {
- TSqlIndex index = enumer.nextElement();
+ for (final Enumeration<TSqlIndex> enumer = this.cachedData.keys(); enumer.hasMoreElements();) {
+ final TSqlIndex index = enumer.nextElement();
if (keyName.equals(index.getResetOn())) {
- cachedData.remove(index);
+ this.cachedData.remove(index);
}
}
}
protected void writeElementBasedIndexes() throws SQLException, DataConfigurationException {
// First, try to get index table
TTable elementTable = null;
- for (TTable ti : sec.getIndexTables()) {
+ for (final TTable ti : this.sec.getIndexTables()) {
if (ti.isMainTable()) {
elementTable = ti;
break;
throw new DataConfigurationException("No table to store element indexes was found !");
}
- StringBuilder sql = new StringBuilder();
- sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + pc.getCollectiviteCodeColname() + "," + pc.getBudgetCodeColname() + ",DOC_ID," + pc.getInitialDocNameColname() + "," + pc.getArchiveNameColname() + ",");
- Vector<Object> valuesToWrite = new Vector<Object>();
- Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
- for (Enumeration<TSqlIndex> enumer = cachedData.keys(); enumer.hasMoreElements();) {
- TSqlIndex index = enumer.nextElement();
- String tableId = index.getTableId();
- TTable sti = sec.getIndexTable(tableId);
+ final StringBuilder sql = new StringBuilder();
+ sql.append("INSERT INTO ").append(elementTable.getBaseName()).append(" (" + this.pc.getCollectiviteCodeColname() + "," + this.pc.getBudgetCodeColname() + ",DOC_ID," + this.pc.getInitialDocNameColname() + "," + this.pc.getArchiveNameColname() + ",");
+ final Vector<Object> valuesToWrite = new Vector<Object>();
+ final Vector<TSqlIndex> indexesToWrite = new Vector<TSqlIndex>();
+ for (final Enumeration<TSqlIndex> enumer = this.cachedData.keys(); enumer.hasMoreElements();) {
+ final TSqlIndex index = enumer.nextElement();
+ final String tableId = index.getTableId();
+ final TTable sti = this.sec.getIndexTable(tableId);
if (sti == elementTable) {
// we are on the element-based table
sql.append(index.getColumn()).append(",");
indexesToWrite.add(index);
- valuesToWrite.add(cachedData.get(index));
- cachedData.remove(index);
+ valuesToWrite.add(this.cachedData.get(index));
+ this.cachedData.remove(index);
}
}
sql.append(")");
PreparedStatement ps = null;
try {
- ps = con.prepareStatement(sql.toString());
- ps.setString(1, collectivite);
- ps.setString(2, budget);
- ps.setString(3, docId);
- ps.setString(4, originFileName);
- if (archiveName == null) {
+ ps = this.con.prepareStatement(sql.toString());
+ ps.setString(1, this.collectivite);
+ ps.setString(2, this.budget);
+ ps.setString(3, this.docId);
+ ps.setString(4, this.originFileName);
+ if (this.archiveName == null) {
ps.setNull(5, Types.VARCHAR);
} else {
- ps.setString(5, archiveName);
+ ps.setString(5, this.archiveName);
}
final int base = 6;
for (int i = 0; i < valuesToWrite.size(); i++) {
- TSqlIndex index = indexesToWrite.elementAt(i);
- Object value = valuesToWrite.elementAt(i);
+ final TSqlIndex index = indexesToWrite.elementAt(i);
+ final Object value = valuesToWrite.elementAt(i);
if (TPersistenceConfig.DATATYPE_DECIMAL.equals(index.getDatatype())) {
- if (value instanceof BigDecimal)
+ if (value instanceof BigDecimal) {
ps.setBigDecimal(i + base, (BigDecimal) value);
- else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ } else {
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_DATE.equals(index.getDatatype())) {
- if (value instanceof Date)
+ if (value instanceof Date) {
ps.setDate(i + base, (Date) value);
- else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ } else {
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_FLOAT.equals(index.getDatatype())) {
- if (value instanceof Float)
+ if (value instanceof Float) {
ps.setFloat(i + base, ((Float) value).floatValue());
- else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ } else {
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_INTEGER.equals(index.getDatatype())) {
- if (value instanceof Integer)
+ if (value instanceof Integer) {
ps.setInt(i + base, ((Integer) value).intValue());
- else {
- logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
- warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
+ } else {
+ OracleDataLayer.logger.warn((value != null ? value.toString() : "<null>") + ": invalid " + index.getDatatype() + " for " + index.getPath());
+ this.warnings.append(value != null ? value.toString() : "<null>").append(": invalid ").append(index.getDatatype()).append(" for ").append(index.getPath()).append("\n");
}
} else if (TPersistenceConfig.DATATYPE_BOOLEAN.equals(index.getDatatype())) {
ps.setInt(i + base, ("true".equals(value) || "1".equals(value)) ? 1 : 0);
ps.executeUpdate();
SQLWarning warn = ps.getWarnings();
while (warn != null) {
- warnings.append(warn.getMessage()).append(" - On table ").append(elementTable.getBaseName()).append("\n");
+ this.warnings.append(warn.getMessage()).append(" - On table ").append(elementTable.getBaseName()).append("\n");
warn = warn.getNextWarning();
}
- } catch (SQLException sqlEx2) {
- StringBuilder sb = new StringBuilder();
+ } catch (final SQLException sqlEx2) {
+ final StringBuilder sb = new StringBuilder();
sb.append("2:inserting into ").append(elementTable.getBaseName()).append(": ").append(sqlEx2.getMessage()).append("\n");
for (int i = 0; i < valuesToWrite.size(); i++) {
- TSqlIndex index = indexesToWrite.elementAt(i);
- Object value = valuesToWrite.elementAt(i);
+ final TSqlIndex index = indexesToWrite.elementAt(i);
+ final Object value = valuesToWrite.elementAt(i);
sb.append("\t").append(index.getColumn()).append(" -> ").append(value != null ? value.toString() : "<null>").append(" (").append(value != null ? value.getClass().getName() : "--").append(")\n");
}
- logger.error(sb.toString());
+ OracleDataLayer.logger.error(sb.toString());
// logger.error("writeElementBasedIndexes()", sqlEx2);
// logger.error("SQL=" + sql);
// logger.error("values=" + valuesToWrite);
if (ps != null) {
try {
ps.close();
- } catch (Throwable t) {
- logger.info("ps closed !", t);
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.info("ps closed !", t);
}
}
}
}
public Exception getException() {
- return sqlEx;
+ return this.sqlEx;
}
public String getWarnings() {
- if (warnings.length() > 0) {
- return warnings.toString();
+ if (this.warnings.length() > 0) {
+ return this.warnings.toString();
}
return null;
}
@Override
- public void characters(char[] ch, int start, int length) throws SAXException {
- StringBuffer sb = datas.peek();
+ public void characters(final char[] ch, final int start, final int length) throws SAXException {
+ final StringBuffer sb = this.datas.peek();
sb.append(ch, start, length);
}
}
* @param propertyName
* @return
*/
- public String getApplicationProperty(String propertyName) {
- return applicationProperties.getProperty(propertyName);
+ public String getApplicationProperty(final String propertyName) {
+ return this.applicationProperties.getProperty(propertyName);
}
private Hashtable<String, TCriteria.FunctionEvaluator> getEvaluatorsFunctions() {
- return evaluators;
+ return OracleDataLayer.evaluators;
}
private static class StrCompareEvaluator implements TCriteria.FunctionEvaluator {
}
@Override
- public String evaluate(String args, CritereModel cm, PropertiesExpansion applicationProperties) throws DataConfigurationException {
- int pos = args.indexOf(',');
- String arg1 = args.substring(0, pos);
- String arg2 = args.substring(pos + 1);
- String comparator = cm.getProperty("OPERATEUR:" + arg2);
- String value = StringEscapeUtils.escapeSql(cm.getProperty("VALEUR:" + arg2));
+ public String evaluate(final String args, final CritereModel cm, final PropertiesExpansion applicationProperties) throws DataConfigurationException {
+ final int pos = args.indexOf(',');
+ final String arg1 = args.substring(0, pos);
+ final String arg2 = args.substring(pos + 1);
+ final String comparator = cm.getProperty("OPERATEUR:" + arg2);
+ final String value = StringEscapeUtils.escapeSql(cm.getProperty("VALEUR:" + arg2));
if ("xem:StringEquals".equals(comparator)) {
return arg1 + "='" + value + "'";
}
@Override
- public String evaluate(String args, CritereModel cm, PropertiesExpansion applicationProperties) throws DataConfigurationException {
- int pos = args.indexOf(',');
- String arg1 = args.substring(0, pos);
- String arg2 = args.substring(pos + 1);
- String comparator = cm.getProperty("OPERATEUR:" + arg2);
- String tmpValue = cm.getProperty("VALEUR:" + arg2);
+ public String evaluate(final String args, final CritereModel cm, final PropertiesExpansion applicationProperties) throws DataConfigurationException {
+ final int pos = args.indexOf(',');
+ final String arg1 = args.substring(0, pos);
+ final String arg2 = args.substring(pos + 1);
+ final String comparator = cm.getProperty("OPERATEUR:" + arg2);
+ final String tmpValue = cm.getProperty("VALEUR:" + arg2);
String value = null;
try {
- SimpleDateFormat sdf = new SimpleDateFormat(applicationProperties.getProperty(Constants.SYS_PROP_DATE_FORMAT));
- java.util.Date d = sdf.parse(tmpValue);
+ final SimpleDateFormat sdf = new SimpleDateFormat(applicationProperties.getProperty(Constants.SYS_PROP_DATE_FORMAT));
+ final java.util.Date d = sdf.parse(tmpValue);
value = StringEscapeUtils.escapeSql(DataLayerManager.getImplementation().getDateFormatter().format(d));
- } catch (Throwable t) {
- logger.error(tmpValue + " is not a valid date");
+ } catch (final Throwable t) {
+ OracleDataLayer.logger.error(tmpValue + " is not a valid date");
}
if (value == null) {
value = tmpValue;
Hashtable<String, PreparedStatement> requetes; // les requetes
Connection con;
- HSWStorageHandle(Hashtable<String, PreparedStatement> preqs, Class[] pclasses, Connection con) {
- classes = pclasses;
- requetes = preqs;
+ HSWStorageHandle(final Hashtable<String, PreparedStatement> preqs, final Class[] pclasses, final Connection con) {
+ this.classes = pclasses;
+ this.requetes = preqs;
this.con = con;
}
- };
+ }
+
}