diff --git a/migration/i1.0a-release/oracle/201212051000_IDEMPIERE_390.sql b/migration/i1.0a-release/oracle/201212051000_IDEMPIERE_390.sql
new file mode 100644
index 0000000000..a1c3bf72ff
--- /dev/null
+++ b/migration/i1.0a-release/oracle/201212051000_IDEMPIERE_390.sql
@@ -0,0 +1,170 @@
+-- Nov 30, 2012 5:06:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('StorageArchive',200257,'D','StorageArchive','Storage Archive','766f13f0-dd9f-4a36-8540-f9f990a81f25',0,TO_DATE('2012-11-30 17:06:06','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-11-30 17:06:06','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
+;
+
+-- Nov 30, 2012 5:06:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Name,Description,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Name,t.Description,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200257 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Element SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', PrintName='Storage Archive_ID',Updated=TO_DATE('2012-11-30 17:11:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Column SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Process_Para SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL, AD_Element_ID=200257 WHERE UPPER(ColumnName)='STORAGEARCHIVE_ID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Process_Para SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Element_ID=200257 AND IsCentrallyMaintained='Y'
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=200257) AND IsCentrallyMaintained='Y'
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_PrintFormatItem pi SET PrintName='Storage Archive_ID', Name='StorageArchive_ID' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=pi.AD_Column_ID AND c.AD_Element_ID=200257)
+;
+
+-- Nov 30, 2012 5:11:22 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,IsAlwaysUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton) VALUES (0,'N','N',0,227,201007,'U','N','N','N',0,'N',22,'N',18,'N',200257,'N','Y','764723f1-4251-4153-8198-0615453fa358','Y','N','StorageArchive_ID','StorageArchive_ID','Y',TO_DATE('2012-11-30 17:11:21','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_DATE('2012-11-30 17:11:21','YYYY-MM-DD HH24:MI:SS'),100,0,'N')
+;
+
+-- Nov 30, 2012 5:11:22 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=201007 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
+;
+
+-- Nov 30, 2012 5:14:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE C_AcctProcessor SET DateNextRun=TO_DATE('2012-11-30 17:24:08','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_DATE('2012-11-30 17:14:08','YYYY-MM-DD HH24:MI:SS'),Updated=TO_DATE('2012-11-30 17:14:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctProcessor_ID=100
+;
+
+-- Nov 30, 2012 5:16:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Reference (AD_Reference_ID,Name,EntityType,AD_Reference_UU,IsOrderByValue,Description,ValidationType,AD_Client_ID,AD_Org_ID,CreatedBy,Updated,IsActive,Created,UpdatedBy) VALUES (200023,'AD_StorageProvider_ID','D','2dc5386f-d9db-4758-a03e-e8695a286ff2','N','AD_StorageProvider_ID','T',0,0,100,TO_DATE('2012-11-30 17:16:07','YYYY-MM-DD HH24:MI:SS'),'Y',TO_DATE('2012-11-30 17:16:07','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Nov 30, 2012 5:16:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Reference_Trl (AD_Language,AD_Reference_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Reference_Trl_UU ) SELECT l.AD_Language,t.AD_Reference_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Reference t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Reference_ID=200023 AND NOT EXISTS (SELECT * FROM AD_Reference_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Reference_ID=t.AD_Reference_ID)
+;
+
+-- Nov 30, 2012 5:17:00 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Ref_Table (IsValueDisplayed,AD_Reference_ID,AD_Key,AD_Display,EntityType,AD_Table_ID,AD_Ref_Table_UU,CreatedBy,Updated,Created,AD_Client_ID,UpdatedBy,AD_Org_ID,IsActive) VALUES ('N',200023,200961,200969,'D',200037,'2d31b980-72b5-4c2e-964b-91fa288f0a12',100,TO_DATE('2012-11-30 17:17:00','YYYY-MM-DD HH24:MI:SS'),TO_DATE('2012-11-30 17:17:00','YYYY-MM-DD HH24:MI:SS'),0,100,0,'Y')
+;
+
+-- Nov 30, 2012 5:17:57 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Column SET AD_Reference_Value_ID=200023,Updated=TO_DATE('2012-11-30 17:17:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=201007
+;
+
+-- Nov 30, 2012 5:18:10 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+ALTER TABLE AD_ClientInfo ADD StorageArchive_ID NUMBER(10) DEFAULT NULL
+;
+
+-- Nov 30, 2012 5:20:25 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Field (ColumnSpan,NumLines,SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry) VALUES (1,1,0,'N',169,0,'N','N',201007,240,'Y',200949,'N','D','StorageArchive_ID','40744096-6d57-48e7-8931-6c237ee9ac3c','Y','N',100,0,TO_DATE('2012-11-30 17:20:24','YYYY-MM-DD HH24:MI:SS'),0,100,TO_DATE('2012-11-30 17:20:24','YYYY-MM-DD HH24:MI:SS'),'Y','Y',320,1,'N')
+;
+
+-- Nov 30, 2012 5:20:25 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=200949 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET ColumnSpan=2, SeqNo=120, IsDisplayed='Y', XPosition=4,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200949
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=130,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9201
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=140,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1564
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=150,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1563
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=160,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1562
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=170,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1565
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=180,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1566
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=190,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1567
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=200,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10319
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=210,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10320
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=220,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57531
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=230,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57534
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=240,Updated=TO_DATE('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57535
+;
+
+-- Nov 30, 2012 5:30:06 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Ref_Table SET IsValueDisplayed='Y', AD_Display=200961,Updated=TO_DATE('2012-11-30 17:30:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200023
+;
+
+-- Nov 30, 2012 5:34:49 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Ref_Table SET IsValueDisplayed='N',Updated=TO_DATE('2012-11-30 17:34:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200023
+;
+
diff --git a/migration/i1.0a-release/postgresql/201212051000_IDEMPIERE_390.sql b/migration/i1.0a-release/postgresql/201212051000_IDEMPIERE_390.sql
new file mode 100644
index 0000000000..65bc058a44
--- /dev/null
+++ b/migration/i1.0a-release/postgresql/201212051000_IDEMPIERE_390.sql
@@ -0,0 +1,170 @@
+-- Nov 30, 2012 5:06:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Element (ColumnName,AD_Element_ID,EntityType,Name,PrintName,AD_Element_UU,AD_Client_ID,Created,Updated,AD_Org_ID,CreatedBy,UpdatedBy,IsActive) VALUES ('StorageArchive',200257,'D','StorageArchive','Storage Archive','766f13f0-dd9f-4a36-8540-f9f990a81f25',0,TO_TIMESTAMP('2012-11-30 17:06:06','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-11-30 17:06:06','YYYY-MM-DD HH24:MI:SS'),0,100,100,'Y')
+;
+
+-- Nov 30, 2012 5:06:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Help,PO_Description,PO_Help,Name,Description,PrintName,PO_Name,PO_PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Element_Trl_UU ) SELECT l.AD_Language,t.AD_Element_ID, t.Help,t.PO_Description,t.PO_Help,t.Name,t.Description,t.PrintName,t.PO_Name,t.PO_PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=200257 AND NOT EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Element_ID=t.AD_Element_ID)
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Element SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', PrintName='Storage Archive_ID',Updated=TO_TIMESTAMP('2012-11-30 17:11:05','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Element_Trl SET IsTranslated='N' WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Column SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Element_ID=200257
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Process_Para SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL, AD_Element_ID=200257 WHERE UPPER(ColumnName)='STORAGEARCHIVE_ID' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Process_Para SET ColumnName='StorageArchive_ID', Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Element_ID=200257 AND IsCentrallyMaintained='Y'
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET Name='StorageArchive_ID', Description=NULL, Help=NULL WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=200257) AND IsCentrallyMaintained='Y'
+;
+
+-- Nov 30, 2012 5:11:05 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_PrintFormatItem SET PrintName='Storage Archive_ID', Name='StorageArchive_ID' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=200257)
+;
+
+-- Nov 30, 2012 5:11:22 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Column (SeqNoSelection,IsSyncDatabase,IsEncrypted,Version,AD_Table_ID,AD_Column_ID,EntityType,IsMandatory,IsTranslated,IsIdentifier,SeqNo,IsParent,FieldLength,IsSelectionColumn,AD_Reference_ID,IsKey,AD_Element_ID,IsAutocomplete,IsAllowLogging,AD_Column_UU,IsUpdateable,IsAlwaysUpdateable,ColumnName,Name,IsAllowCopy,Updated,CreatedBy,AD_Org_ID,IsActive,Created,UpdatedBy,AD_Client_ID,IsToolbarButton) VALUES (0,'N','N',0,227,201007,'U','N','N','N',0,'N',22,'N',18,'N',200257,'N','Y','764723f1-4251-4153-8198-0615453fa358','Y','N','StorageArchive_ID','StorageArchive_ID','Y',TO_TIMESTAMP('2012-11-30 17:11:21','YYYY-MM-DD HH24:MI:SS'),100,0,'Y',TO_TIMESTAMP('2012-11-30 17:11:21','YYYY-MM-DD HH24:MI:SS'),100,0,'N')
+;
+
+-- Nov 30, 2012 5:11:22 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Column_Trl_UU ) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=201007 AND NOT EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Column_ID=t.AD_Column_ID)
+;
+
+-- Nov 30, 2012 5:14:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE C_AcctProcessor SET DateNextRun=TO_TIMESTAMP('2012-11-30 17:24:08','YYYY-MM-DD HH24:MI:SS'), DateLastRun=TO_TIMESTAMP('2012-11-30 17:14:08','YYYY-MM-DD HH24:MI:SS'),Updated=TO_TIMESTAMP('2012-11-30 17:14:08','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE C_AcctProcessor_ID=100
+;
+
+-- Nov 30, 2012 5:16:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Reference (AD_Reference_ID,Name,EntityType,AD_Reference_UU,IsOrderByValue,Description,ValidationType,AD_Client_ID,AD_Org_ID,CreatedBy,Updated,IsActive,Created,UpdatedBy) VALUES (200023,'AD_StorageProvider_ID','D','2dc5386f-d9db-4758-a03e-e8695a286ff2','N','AD_StorageProvider_ID','T',0,0,100,TO_TIMESTAMP('2012-11-30 17:16:07','YYYY-MM-DD HH24:MI:SS'),'Y',TO_TIMESTAMP('2012-11-30 17:16:07','YYYY-MM-DD HH24:MI:SS'),100)
+;
+
+-- Nov 30, 2012 5:16:08 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Reference_Trl (AD_Language,AD_Reference_ID, Help,Name,Description, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Reference_Trl_UU ) SELECT l.AD_Language,t.AD_Reference_ID, t.Help,t.Name,t.Description, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Reference t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Reference_ID=200023 AND NOT EXISTS (SELECT * FROM AD_Reference_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Reference_ID=t.AD_Reference_ID)
+;
+
+-- Nov 30, 2012 5:17:00 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Ref_Table (IsValueDisplayed,AD_Reference_ID,AD_Key,AD_Display,EntityType,AD_Table_ID,AD_Ref_Table_UU,CreatedBy,Updated,Created,AD_Client_ID,UpdatedBy,AD_Org_ID,IsActive) VALUES ('N',200023,200961,200969,'D',200037,'2d31b980-72b5-4c2e-964b-91fa288f0a12',100,TO_TIMESTAMP('2012-11-30 17:17:00','YYYY-MM-DD HH24:MI:SS'),TO_TIMESTAMP('2012-11-30 17:17:00','YYYY-MM-DD HH24:MI:SS'),0,100,0,'Y')
+;
+
+-- Nov 30, 2012 5:17:57 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Column SET AD_Reference_Value_ID=200023,Updated=TO_TIMESTAMP('2012-11-30 17:17:57','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=201007
+;
+
+-- Nov 30, 2012 5:18:10 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+ALTER TABLE AD_ClientInfo ADD COLUMN StorageArchive_ID NUMERIC(10) DEFAULT NULL
+;
+
+-- Nov 30, 2012 5:20:25 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Field (ColumnSpan,NumLines,SortNo,IsEncrypted,AD_Tab_ID,DisplayLength,IsSameLine,IsHeading,AD_Column_ID,SeqNo,IsCentrallyMaintained,AD_Field_ID,IsReadOnly,EntityType,Name,AD_Field_UU,IsDisplayed,IsFieldOnly,UpdatedBy,AD_Org_ID,Created,AD_Client_ID,CreatedBy,Updated,IsActive,IsDisplayedGrid,SeqNoGrid,XPosition,IsQuickEntry) VALUES (1,1,0,'N',169,0,'N','N',201007,240,'Y',200949,'N','D','StorageArchive_ID','40744096-6d57-48e7-8931-6c237ee9ac3c','Y','N',100,0,TO_TIMESTAMP('2012-11-30 17:20:24','YYYY-MM-DD HH24:MI:SS'),0,100,TO_TIMESTAMP('2012-11-30 17:20:24','YYYY-MM-DD HH24:MI:SS'),'Y','Y',320,1,'N')
+;
+
+-- Nov 30, 2012 5:20:25 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Help,Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy,AD_Field_Trl_UU ) SELECT l.AD_Language,t.AD_Field_ID, t.Help,t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy,Generate_UUID() FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=200949 AND NOT EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language=l.AD_Language AND tt.AD_Field_ID=t.AD_Field_ID)
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET ColumnSpan=2, SeqNo=120, IsDisplayed='Y', XPosition=4,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=200949
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=130,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=9201
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=140,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1564
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=150,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1563
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=160,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1562
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=170,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1565
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=180,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1566
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=190,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=1567
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=200,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10319
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=210,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=10320
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=220,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57531
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=230,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57534
+;
+
+-- Nov 30, 2012 5:20:54 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Field SET SeqNo=240,Updated=TO_TIMESTAMP('2012-11-30 17:20:54','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Field_ID=57535
+;
+
+-- Nov 30, 2012 5:30:06 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Ref_Table SET IsValueDisplayed='Y', AD_Display=200961,Updated=TO_TIMESTAMP('2012-11-30 17:30:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200023
+;
+
+-- Nov 30, 2012 5:34:49 PM COT
+-- IDEMPIERE-390 Attachments/archives on load balancer scenario
+UPDATE AD_Ref_Table SET IsValueDisplayed='N',Updated=TO_TIMESTAMP('2012-11-30 17:34:49','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Reference_ID=200023
+;
+
diff --git a/org.adempiere.base/META-INF/MANIFEST.MF b/org.adempiere.base/META-INF/MANIFEST.MF
index 8480db8d8c..1498ed8eef 100644
--- a/org.adempiere.base/META-INF/MANIFEST.MF
+++ b/org.adempiere.base/META-INF/MANIFEST.MF
@@ -291,6 +291,6 @@ Import-Package: com.sun.mail.auth;version="1.4.5",
Eclipse-BuddyPolicy: registered
Eclipse-ExtensibleAPI: true
Bundle-Activator: org.adempiere.base.BaseActivator
-Service-Component: OSGI-INF/eventmanager.xml, OSGI-INF/dslocator.xml, OSGI-INF/extensionlocator.xml, OSGI-INF/serverbean.xml, OSGI-INF/statusbean.xml, OSGI-INF/defaultmodelfactory.xml, OSGI-INF/defaultdocfactory.xml, OSGI-INF/AttachmentFile.xml, OSGI-INF/AttachmentDB.xml
+Service-Component: OSGI-INF/eventmanager.xml, OSGI-INF/dslocator.xml, OSGI-INF/extensionlocator.xml, OSGI-INF/serverbean.xml, OSGI-INF/statusbean.xml, OSGI-INF/defaultmodelfactory.xml, OSGI-INF/defaultdocfactory.xml, OSGI-INF/attachmentfile.xml, OSGI-INF/attachmentDB.xml,OSGI-INF/archiveDB.xml,OSGI-INF/archivefile.xml
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.equinox.app;bundle-version="1.3.1"
diff --git a/org.adempiere.base/OSGI-INF/archiveDB.xml b/org.adempiere.base/OSGI-INF/archiveDB.xml
new file mode 100644
index 0000000000..62d621d6d7
--- /dev/null
+++ b/org.adempiere.base/OSGI-INF/archiveDB.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/org.adempiere.base/OSGI-INF/archivefile.xml b/org.adempiere.base/OSGI-INF/archivefile.xml
new file mode 100644
index 0000000000..5bf0bef013
--- /dev/null
+++ b/org.adempiere.base/OSGI-INF/archivefile.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
diff --git a/org.adempiere.base/OSGI-INF/AttachmentDB.xml b/org.adempiere.base/OSGI-INF/attachmentDB.xml
similarity index 85%
rename from org.adempiere.base/OSGI-INF/AttachmentDB.xml
rename to org.adempiere.base/OSGI-INF/attachmentDB.xml
index 51232ec3a1..38256bc5dd 100644
--- a/org.adempiere.base/OSGI-INF/AttachmentDB.xml
+++ b/org.adempiere.base/OSGI-INF/attachmentDB.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/org.adempiere.base/OSGI-INF/AttachmentFile.xml b/org.adempiere.base/OSGI-INF/attachmentfile.xml
similarity index 85%
rename from org.adempiere.base/OSGI-INF/AttachmentFile.xml
rename to org.adempiere.base/OSGI-INF/attachmentfile.xml
index 41b3a0535b..f04bf80d2f 100644
--- a/org.adempiere.base/OSGI-INF/AttachmentFile.xml
+++ b/org.adempiere.base/OSGI-INF/attachmentfile.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/org.adempiere.base/src/org/compiere/model/ArchiveDB.java b/org.adempiere.base/src/org/compiere/model/ArchiveDB.java
new file mode 100644
index 0000000000..6849384f8e
--- /dev/null
+++ b/org.adempiere.base/src/org/compiere/model/ArchiveDB.java
@@ -0,0 +1,117 @@
+/******************************************************************************
+ * Product: iDempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 2012 Trek Global *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.logging.Level;
+import java.util.zip.Deflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import org.compiere.util.CLogger;
+
+/**
+ * @author juliana
+ *
+ */
+public class ArchiveDB implements IArchiveStore {
+
+
+ private final CLogger log = CLogger.getCLogger(getClass());
+
+ /* (non-Javadoc)
+ * @see org.compiere.model.IArchiveStore#loadLOBData(org.compiere.model.MArchive, org.compiere.model.MStorageProvider)
+ */
+ @Override
+ public byte[] loadLOBData(MArchive archive, MStorageProvider prov) {
+ byte[] deflatedData = archive.getByteData();
+ archive.m_deflated = null;
+ archive.m_inflated = null;
+ if (deflatedData == null)
+ return null;
+ //
+ log.fine("ZipSize=" + deflatedData.length);
+ archive.m_deflated = new Integer(deflatedData.length);
+ if (deflatedData.length == 0)
+ return null;
+
+ byte[] inflatedData = null;
+ try {
+ ByteArrayInputStream in = new ByteArrayInputStream(deflatedData);
+ ZipInputStream zip = new ZipInputStream(in);
+ ZipEntry entry = zip.getNextEntry();
+ if (entry != null) // just one entry
+ {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ byte[] buffer = new byte[2048];
+ int length = zip.read(buffer);
+ while (length != -1) {
+ out.write(buffer, 0, length);
+ length = zip.read(buffer);
+ }
+ //
+ inflatedData = out.toByteArray();
+ log.fine("Size=" + inflatedData.length + " - zip=" + entry.getCompressedSize()
+ + "(" + entry.getSize() + ") "
+ + (entry.getCompressedSize() * 100 / entry.getSize()) + "%");
+ archive.m_inflated = new Integer(inflatedData.length);
+ }
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "", e);
+ inflatedData = null;
+ }
+ return inflatedData;
+ }
+
+ /* (non-Javadoc)
+ * @see org.compiere.model.IArchiveStore#save(org.compiere.model.MArchive, org.compiere.model.MStorageProvider, byte[])
+ */
+ @Override
+ public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData) {
+ if (inflatedData == null || inflatedData.length == 0)
+ throw new IllegalArgumentException("InflatedData is NULL");
+ archive.m_inflated = new Integer(inflatedData.length);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ZipOutputStream zip = new ZipOutputStream(out);
+ zip.setMethod(ZipOutputStream.DEFLATED);
+ zip.setLevel(Deflater.BEST_COMPRESSION);
+ zip.setComment("idempiere");
+ //
+ byte[] deflatedData = null;
+ try {
+ ZipEntry entry = new ZipEntry("IdempiereArchive");
+ entry.setTime(System.currentTimeMillis());
+ entry.setMethod(ZipEntry.DEFLATED);
+ zip.putNextEntry(entry);
+ zip.write(inflatedData, 0, inflatedData.length);
+ zip.closeEntry();
+ log.fine(entry.getCompressedSize() + " (" + entry.getSize() + ") "
+ + (entry.getCompressedSize() * 100 / entry.getSize()) + "%");
+ //
+ // zip.finish();
+ zip.close();
+ deflatedData = out.toByteArray();
+ log.fine("Length=" + inflatedData.length);
+ archive.m_deflated = new Integer(deflatedData.length);
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "saveLOBData", e);
+ deflatedData = null;
+ archive.m_deflated = null;
+ }
+ archive.setByteData(deflatedData);
+ }
+
+}
diff --git a/org.adempiere.base/src/org/compiere/model/ArchiveFileSystem.java b/org.adempiere.base/src/org/compiere/model/ArchiveFileSystem.java
new file mode 100644
index 0000000000..6c291e33e2
--- /dev/null
+++ b/org.adempiere.base/src/org/compiere/model/ArchiveFileSystem.java
@@ -0,0 +1,216 @@
+/******************************************************************************
+ * Product: iDempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 2012 Trek Global *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+
+package org.compiere.model;
+
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.logging.Level;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.Result;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamResult;
+
+import org.compiere.util.CLogger;
+import org.w3c.dom.Document;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+import org.w3c.dom.Element;
+
+/**
+ * @author juliana
+ *
+ */
+public class ArchiveFileSystem implements IArchiveStore {
+
+ private String ARCHIVE_FOLDER_PLACEHOLDER = "%ARCHIVE_FOLDER%";
+
+ private final CLogger log = CLogger.getCLogger(getClass());
+
+
+ /* (non-Javadoc)
+ * @see org.compiere.model.IArchiveStore#loadLOBData(org.compiere.model.MArchive, org.compiere.model.MStorageProvider)
+ */
+ @Override
+ public byte[] loadLOBData(MArchive archive, MStorageProvider prov) {
+ if ("".equals(archive.m_archivePathRoot)) {
+ throw new IllegalArgumentException("no attachmentPath defined");
+ }
+ byte[] data = archive.getByteData();
+ archive.m_deflated = null;
+ archive.m_inflated = null;
+ if (data == null) {
+ return null;
+ }
+
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+
+ try {
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document document = builder.parse(new ByteArrayInputStream(data));
+ final NodeList entries = document.getElementsByTagName("entry");
+ if(entries.getLength()!=1){
+ log.severe("no archive entry found");
+ }
+ final Node entryNode = entries.item(0);
+ final NamedNodeMap attributes = entryNode.getAttributes();
+ final Node fileNode = attributes.getNamedItem("file");
+ if(fileNode==null ){
+ log.severe("no filename for entry");
+ return null;
+ }
+ String filePath = fileNode.getNodeValue();
+ log.fine("filePath: " + filePath);
+ if(filePath!=null){
+ filePath = filePath.replaceFirst(ARCHIVE_FOLDER_PLACEHOLDER, archive.m_archivePathRoot.replaceAll("\\\\","\\\\\\\\"));
+ //just to be shure...
+ String replaceSeparator = File.separator;
+ if(!replaceSeparator.equals("/")){
+ replaceSeparator = "\\\\";
+ }
+ filePath = filePath.replaceAll("/", replaceSeparator);
+ filePath = filePath.replaceAll("\\\\", replaceSeparator);
+ }
+ log.fine("filePath: " + filePath);
+ final File file = new File(filePath);
+ if (file.exists()) {
+ // read files into byte[]
+ final byte[] dataEntry = new byte[(int) file.length()];
+ try {
+ final FileInputStream fileInputStream = new FileInputStream(file);
+ fileInputStream.read(dataEntry);
+ fileInputStream.close();
+ } catch (FileNotFoundException e) {
+ log.severe("File Not Found.");
+ e.printStackTrace();
+ } catch (IOException e1) {
+ log.severe("Error Reading The File.");
+ e1.printStackTrace();
+ }
+ return dataEntry;
+ } else {
+ log.severe("file not found: " + file.getAbsolutePath());
+ return null;
+ }
+
+ } catch (SAXException sxe) {
+ // Error generated during parsing)
+ Exception x = sxe;
+ if (sxe.getException() != null)
+ x = sxe.getException();
+ x.printStackTrace();
+ log.severe(x.getMessage());
+
+ } catch (ParserConfigurationException pce) {
+ // Parser with specified options can't be built
+ pce.printStackTrace();
+ log.severe(pce.getMessage());
+
+ } catch (IOException ioe) {
+ // I/O error
+ ioe.printStackTrace();
+ log.severe(ioe.getMessage());
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.compiere.model.IArchiveStore#save(org.compiere.model.MArchive, org.compiere.model.MStorageProvider)
+ */
+ @Override
+ public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData) {
+ if ("".equals(archive.m_archivePathRoot)) {
+ throw new IllegalArgumentException("no attachmentPath defined");
+ }
+ if (inflatedData == null || inflatedData.length == 0) {
+ throw new IllegalArgumentException("InflatedData is NULL");
+ }
+ if(archive.get_ID()==0){
+ //set binary data otherwise save will fail
+ archive.setByteData(new byte[]{'0'});
+ if(!archive.save()) {
+ throw new IllegalArgumentException("unable to save MArchive");
+ }
+ }
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ BufferedOutputStream out = null;
+ try {
+ // create destination folder
+ StringBuilder msgfile = new StringBuilder().append(archive.m_archivePathRoot).append(File.separator)
+ .append(archive.getArchivePathSnippet());
+ final File destFolder = new File(msgfile.toString());
+ if (!destFolder.exists()) {
+ if (!destFolder.mkdirs()) {
+ log.warning("unable to create folder: " + destFolder.getPath());
+ }
+ }
+ // write to pdf
+ msgfile = new StringBuilder().append(archive.m_archivePathRoot).append(File.separator)
+ .append(archive.getArchivePathSnippet()).append(archive.get_ID()).append(".pdf");
+ final File destFile = new File(msgfile.toString());
+
+ out = new BufferedOutputStream(new FileOutputStream(destFile));
+ out.write(inflatedData);
+ out.flush();
+
+ //create xml entry
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document document = builder.newDocument();
+ final Element root = document.createElement("archive");
+ document.appendChild(root);
+ document.setXmlStandalone(true);
+ final Element entry = document.createElement("entry");
+ StringBuilder msgsat = new StringBuilder(ARCHIVE_FOLDER_PLACEHOLDER).append(archive.getArchivePathSnippet()).append(archive.get_ID()).append(".pdf");
+ entry.setAttribute("file", msgsat.toString());
+ root.appendChild(entry);
+ final Source source = new DOMSource(document);
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final Result result = new StreamResult(bos);
+ final Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.transform(source, result);
+ final byte[] xmlData = bos.toByteArray();
+ log.fine(bos.toString());
+ //store xml in db
+ archive.setByteData(xmlData);
+
+ } catch (Exception e) {
+ log.log(Level.SEVERE, "saveLOBData", e);
+ archive.m_deflated = null;
+ archive.setByteData(null);
+ } finally {
+ if(out != null){
+ try {
+ out.close();
+ } catch (Exception e) { }
+ }
+ }
+
+ }
+
+}
diff --git a/org.adempiere.base/src/org/compiere/model/IArchiveStore.java b/org.adempiere.base/src/org/compiere/model/IArchiveStore.java
new file mode 100644
index 0000000000..f3a7ea92ea
--- /dev/null
+++ b/org.adempiere.base/src/org/compiere/model/IArchiveStore.java
@@ -0,0 +1,23 @@
+/******************************************************************************
+ * Product: iDempiere ERP & CRM Smart Business Solution *
+ * Copyright (C) 2012 Trek Global *
+ * This program is free software; you can redistribute it and/or modify it *
+ * under the terms version 2 of the GNU General Public License as published *
+ * by the Free Software Foundation. This program is distributed in the hope *
+ * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
+ * See the GNU General Public License for more details. *
+ * You should have received a copy of the GNU General Public License along *
+ * with this program; if not, write to the Free Software Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
+ *****************************************************************************/
+package org.compiere.model;
+
+public interface IArchiveStore {
+
+ public byte[] loadLOBData(MArchive archive,MStorageProvider prov);
+
+ public void save(MArchive archive, MStorageProvider prov,byte[] inflatedData);
+
+
+}
diff --git a/org.adempiere.base/src/org/compiere/model/I_AD_ClientInfo.java b/org.adempiere.base/src/org/compiere/model/I_AD_ClientInfo.java
index e7dbd8fee7..84f5c931ab 100644
--- a/org.adempiere.base/src/org/compiere/model/I_AD_ClientInfo.java
+++ b/org.adempiere.base/src/org/compiere/model/I_AD_ClientInfo.java
@@ -74,10 +74,10 @@ public interface I_AD_ClientInfo
/** Column name AD_StorageProvider_ID */
public static final String COLUMNNAME_AD_StorageProvider_ID = "AD_StorageProvider_ID";
- /** Set AD_StorageProvider_ID */
+ /** Set Storage Provider */
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID);
- /** Get AD_StorageProvider_ID */
+ /** Get Storage Provider */
public int getAD_StorageProvider_ID();
public org.compiere.model.I_AD_StorageProvider getAD_StorageProvider() throws RuntimeException;
@@ -400,6 +400,17 @@ public interface I_AD_ClientInfo
public org.compiere.model.I_M_Product getM_ProductFreight() throws RuntimeException;
+ /** Column name StorageArchive_ID */
+ public static final String COLUMNNAME_StorageArchive_ID = "StorageArchive_ID";
+
+ /** Set StorageArchive_ID */
+ public void setStorageArchive_ID (int StorageArchive_ID);
+
+ /** Get StorageArchive_ID */
+ public int getStorageArchive_ID();
+
+ public org.compiere.model.I_AD_StorageProvider getStorageArchive() throws RuntimeException;
+
/** Column name Updated */
public static final String COLUMNNAME_Updated = "Updated";
diff --git a/org.adempiere.base/src/org/compiere/model/MArchive.java b/org.adempiere.base/src/org/compiere/model/MArchive.java
index 4d3b747fa6..578cf9a7f3 100644
--- a/org.adempiere.base/src/org/compiere/model/MArchive.java
+++ b/org.adempiere.base/src/org/compiere/model/MArchive.java
@@ -116,9 +116,9 @@ public class MArchive extends X_AD_Archive {
/** Logger */
private static CLogger s_log = CLogger.getCLogger(MArchive.class);
- private Integer m_inflated = null;
+ public Integer m_inflated = null;
- private Integer m_deflated = null;
+ public Integer m_deflated = null;
/***************************************************************************
* Standard Constructor
@@ -176,7 +176,7 @@ public class MArchive extends X_AD_Archive {
private boolean isStoreArchiveOnFileSystem = false;
/** archive (root) path - if file system is used */
- private String m_archivePathRoot = "";
+ public String m_archivePathRoot = "";
/**
* string replaces the archive root in stored xml file to allow the
@@ -184,6 +184,7 @@ public class MArchive extends X_AD_Archive {
*/
private final String ARCHIVE_FOLDER_PLACEHOLDER = "%ARCHIVE_FOLDER%";
+ public MStorageProvider provider;
/**
* Get the isStoreArchiveOnFileSystem and archivePath for the client.
*
@@ -191,7 +192,22 @@ public class MArchive extends X_AD_Archive {
* @param trxName
*/
private void initArchiveStoreDetails(Properties ctx, String trxName) {
- final MClient client = new MClient(ctx, this.getAD_Client_ID(), trxName);
+
+ MClientInfo clientInfo = MClientInfo.get(ctx);
+
+ provider=new MStorageProvider(ctx, clientInfo.getStorageArchive_ID(), trxName);
+
+ m_archivePathRoot=provider.getFolder();
+
+ if(m_archivePathRoot == null){
+ log.severe("no attachmentPath defined");
+ } else if (!m_archivePathRoot.endsWith(File.separator)) {
+ log.warning("archive path doesn't end with " + File.separator);
+ m_archivePathRoot = m_archivePathRoot + File.separator;
+ log.fine(m_archivePathRoot);
+ }
+
+ /*final MClient client = new MClient(ctx, this.getAD_Client_ID(), trxName);
isStoreArchiveOnFileSystem = client.isStoreArchiveOnFileSystem();
if (isStoreArchiveOnFileSystem) {
if (File.separatorChar == '\\') {
@@ -206,7 +222,7 @@ public class MArchive extends X_AD_Archive {
m_archivePathRoot = m_archivePathRoot + File.separator;
log.fine(m_archivePathRoot);
}
- }
+ }*/
}
/**
@@ -226,12 +242,13 @@ public class MArchive extends X_AD_Archive {
} // toString
public byte[] getBinaryData() {
- if (isStoreArchiveOnFileSystem) {
- return getBinaryDataFromFileSystem();
- }
- return getBinaryDataFromDB();
+
+ IArchiveStore prov = provider.getArchiveStore();
+ if (prov != null)
+ return prov.loadLOBData(this,provider);
+ return null;
}
-
+
/**
* @return attachment data
*/
@@ -381,11 +398,17 @@ public class MArchive extends X_AD_Archive {
* inflated data
*/
public void setBinaryData(byte[] inflatedData) {
- if (isStoreArchiveOnFileSystem) {
+ IArchiveStore prov = provider.getArchiveStore();
+ if (prov != null)
+ prov.save(this,provider,inflatedData);
+
+
+
+ /*if (isStoreArchiveOnFileSystem) {
saveBinaryDataIntoFileSystem(inflatedData);
} else {
saveBinaryDataIntoDB(inflatedData);
- }
+ }*/
}
/**
@@ -540,7 +563,7 @@ public class MArchive extends X_AD_Archive {
*
* @return String
*/
- private String getArchivePathSnippet() {
+ public String getArchivePathSnippet() {
StringBuilder path = new StringBuilder().append(this.getAD_Client_ID()).append(File.separator).append(this.getAD_Org_ID())
.append(File.separator);
if (this.getAD_Process_ID() > 0) {
@@ -563,7 +586,7 @@ public class MArchive extends X_AD_Archive {
* new
* @return true if can be saved
*/
- protected boolean beforeSave(boolean newRecord) {
+ /*protected boolean beforeSave(boolean newRecord) {
// Binary Data is Mandatory
byte[] data = super.getBinaryData();
if (data == null || data.length == 0)
@@ -571,6 +594,15 @@ public class MArchive extends X_AD_Archive {
//
log.fine(toString());
return true;
- } // beforeSave
+ } // beforeSave*/
+
+
+ public byte[] getByteData(){
+ return super.getBinaryData();
+ }
+
+ public void setByteData(byte[] BinaryData){
+ super.setBinaryData(BinaryData);
+ }
} // MArchive
diff --git a/org.adempiere.base/src/org/compiere/model/MStorageProvider.java b/org.adempiere.base/src/org/compiere/model/MStorageProvider.java
index aaccf8160f..e81cfd9cf1 100644
--- a/org.adempiere.base/src/org/compiere/model/MStorageProvider.java
+++ b/org.adempiere.base/src/org/compiere/model/MStorageProvider.java
@@ -45,16 +45,30 @@ public class MStorageProvider extends X_AD_StorageProvider {
if (method == null)
method = "DB";
query.put("method", method);
- List storelist = Service.locator().list(IAttachmentStore.class, query).getServices();
-
- IAttachmentStore store = null;
- if (storelist == null) {
+ IAttachmentStore store = Service.locator().locate(IAttachmentStore.class, query).getService();
+ if(store == null){
log.saveError("Error", "No storage provider found");
- } else {
- store = storelist.get(0);
+
}
return store;
}
+
+ public IArchiveStore getArchiveStore(){
+
+ ServiceQuery query=new ServiceQuery();
+ String method = this.getMethod();
+ if (method == null)
+ method = "DB";
+ query.put("storage", method);
+ IArchiveStore store = Service.locator().locate(IArchiveStore.class, query).getService();
+
+ if(store == null){
+ log.saveError("Error", "No storage provider found");
+
+ }
+ return store;
+
+ }
}
diff --git a/org.adempiere.base/src/org/compiere/model/X_AD_ClientInfo.java b/org.adempiere.base/src/org/compiere/model/X_AD_ClientInfo.java
index 75d218a3a9..221e2cb150 100644
--- a/org.adempiere.base/src/org/compiere/model/X_AD_ClientInfo.java
+++ b/org.adempiere.base/src/org/compiere/model/X_AD_ClientInfo.java
@@ -29,7 +29,7 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
/**
*
*/
- private static final long serialVersionUID = 20121127L;
+ private static final long serialVersionUID = 20121205L;
/** Standard Constructor */
public X_AD_ClientInfo (Properties ctx, int AD_ClientInfo_ID, String trxName)
@@ -88,8 +88,8 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
return (org.compiere.model.I_AD_StorageProvider)MTable.get(getCtx(), org.compiere.model.I_AD_StorageProvider.Table_Name)
.getPO(getAD_StorageProvider_ID(), get_TrxName()); }
- /** Set AD_StorageProvider_ID.
- @param AD_StorageProvider_ID AD_StorageProvider_ID */
+ /** Set Storage Provider.
+ @param AD_StorageProvider_ID Storage Provider */
public void setAD_StorageProvider_ID (int AD_StorageProvider_ID)
{
if (AD_StorageProvider_ID < 1)
@@ -98,8 +98,8 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
set_Value (COLUMNNAME_AD_StorageProvider_ID, Integer.valueOf(AD_StorageProvider_ID));
}
- /** Get AD_StorageProvider_ID.
- @return AD_StorageProvider_ID */
+ /** Get Storage Provider.
+ @return Storage Provider */
public int getAD_StorageProvider_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_AD_StorageProvider_ID);
@@ -656,4 +656,29 @@ public class X_AD_ClientInfo extends PO implements I_AD_ClientInfo, I_Persistent
return 0;
return ii.intValue();
}
+
+ public org.compiere.model.I_AD_StorageProvider getStorageArchive() throws RuntimeException
+ {
+ return (org.compiere.model.I_AD_StorageProvider)MTable.get(getCtx(), org.compiere.model.I_AD_StorageProvider.Table_Name)
+ .getPO(getStorageArchive_ID(), get_TrxName()); }
+
+ /** Set StorageArchive_ID.
+ @param StorageArchive_ID StorageArchive_ID */
+ public void setStorageArchive_ID (int StorageArchive_ID)
+ {
+ if (StorageArchive_ID < 1)
+ set_Value (COLUMNNAME_StorageArchive_ID, null);
+ else
+ set_Value (COLUMNNAME_StorageArchive_ID, Integer.valueOf(StorageArchive_ID));
+ }
+
+ /** Get StorageArchive_ID.
+ @return StorageArchive_ID */
+ public int getStorageArchive_ID ()
+ {
+ Integer ii = (Integer)get_Value(COLUMNNAME_StorageArchive_ID);
+ if (ii == null)
+ return 0;
+ return ii.intValue();
+ }
}
\ No newline at end of file