hg merge release-2.0 (merge release2 into development)

This commit is contained in:
Carlos Ruiz 2014-04-23 18:20:20 -05:00
commit e7a19cb6b0
7 changed files with 92 additions and 39 deletions

View File

@ -0,0 +1,10 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- Apr 8, 2014 3:18:45 PM CEST
-- IDEMPIERE-1891
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200269,'0b36ffa9-8364-4d93-8d9a-1e3eae4aa81b',0,TO_DATE('2014-04-08 15:18:44','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','You cannot access process {0} with your role : {1}','I',TO_DATE('2014-04-08 15:18:44','YYYY-MM-DD HH24:MI:SS'),100,'CannotAccessProcess')
;
SELECT register_migration_script('201404081520_IDEMPIERE-1891.sql') FROM dual
;

View File

@ -0,0 +1,7 @@
-- Apr 8, 2014 3:18:45 PM CEST
-- IDEMPIERE-1891
INSERT INTO AD_Message (AD_Client_ID,AD_Message_ID,AD_Message_UU,AD_Org_ID,Created,CreatedBy,EntityType,IsActive,MsgText,MsgType,Updated,UpdatedBy,Value) VALUES (0,200269,'0b36ffa9-8364-4d93-8d9a-1e3eae4aa81b',0,TO_TIMESTAMP('2014-04-08 15:18:44','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','You cannot access process {0} with your role : {1}','I',TO_TIMESTAMP('2014-04-08 15:18:44','YYYY-MM-DD HH24:MI:SS'),100,'CannotAccessProcess')
;
SELECT register_migration_script('201404081520_IDEMPIERE-1891.sql') FROM dual
;

View File

@ -326,7 +326,7 @@ public class ImportProduct extends SvrProcess implements ImportProcess
// Verify ProductType // Verify ProductType
sql = new StringBuilder ("UPDATE I_Product ") sql = new StringBuilder ("UPDATE I_Product ")
.append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProductType,' ") .append("SET I_IsImported='E', I_ErrorMsg=I_ErrorMsg||'ERR=Invalid ProductType,' ")
.append("WHERE ProductType NOT IN ('E','I','R','S')") .append("WHERE ProductType NOT IN ('E','I','R','S','A')")
.append(" AND I_IsImported<>'Y'").append(clientCheck); .append(" AND I_IsImported<>'Y'").append(clientCheck);
no = DB.executeUpdate(sql.toString(), get_TrxName()); no = DB.executeUpdate(sql.toString(), get_TrxName());
if (no != 0) if (no != 0)

View File

@ -19,6 +19,7 @@ package org.compiere.process;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.net.UnknownHostException;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
@ -38,7 +39,9 @@ import javax.mail.Part;
import javax.mail.Session; import javax.mail.Session;
import javax.mail.Store; import javax.mail.Store;
import org.adempiere.exceptions.AdempiereException;
import org.compiere.model.MAttachment; import org.compiere.model.MAttachment;
import org.compiere.model.MColumn;
import org.compiere.model.MRequest; import org.compiere.model.MRequest;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
@ -54,6 +57,7 @@ import org.compiere.util.EMailAuthenticator;
public class RequestEMailProcessor extends SvrProcess public class RequestEMailProcessor extends SvrProcess
{ {
protected String p_IMAPHost = null; protected String p_IMAPHost = null;
protected int p_IMAPPort = 143;
protected String p_IMAPUser = null; protected String p_IMAPUser = null;
protected String p_IMAPPwd = null; protected String p_IMAPPwd = null;
protected String p_RequestFolder = null; protected String p_RequestFolder = null;
@ -133,7 +137,20 @@ public class RequestEMailProcessor extends SvrProcess
*/ */
protected String doIt() throws Exception protected String doIt() throws Exception
{ {
int portStartIndex = p_IMAPHost.lastIndexOf(":");
if (portStartIndex > 0){
String strPort = p_IMAPHost.substring(portStartIndex + 1, p_IMAPHost.length());
p_IMAPHost = p_IMAPHost.substring(0, portStartIndex);
try{
p_IMAPPort = Integer.parseInt(strPort);
}catch (Exception ex){
throw new AdempiereException("Error format port : " + strPort);
}
}else if (p_IMAPHost.startsWith("imap.gmail.com")){
p_IMAPPort = 993;
}
if (log.isLoggable(Level.INFO)) log.info("doIt - IMAPHost=" + p_IMAPHost + if (log.isLoggable(Level.INFO)) log.info("doIt - IMAPHost=" + p_IMAPHost +
" IMAPPort=" + p_IMAPPort +
" IMAPUser=" + p_IMAPUser + " IMAPUser=" + p_IMAPUser +
// " IMAPPwd=" + p_IMAPPwd + // " IMAPPwd=" + p_IMAPPwd +
" RequestFolder=" + p_RequestFolder + " RequestFolder=" + p_RequestFolder +
@ -145,19 +162,25 @@ public class RequestEMailProcessor extends SvrProcess
getSession(); getSession();
getStore(); getStore();
processInBox(); processInBox();
} catch (MessagingException mailEx) {
if (mailEx.getNextException() != null && mailEx.getNextException() instanceof UnknownHostException){
throw new AdempiereException("Error host : " + mailEx.getMessage());
} else {
throw new AdempiereException("Error when make connect to email server : " + mailEx.getMessage());
}
} catch (AdempiereException ae) {
throw ae;
} }
catch (Exception e) catch (Exception e) {
{
log.log(Level.SEVERE, "processInBox", e); log.log(Level.SEVERE, "processInBox", e);
} throw e;
// Cleanup }finally {
try // Cleanup
{ try
if (m_store.isConnected()) {
m_store.close(); if ( m_store != null && m_store.isConnected())
} m_store.close();
catch (Exception e) } catch(Exception ex) {}
{
} }
StringBuilder msgreturn = new StringBuilder("processInBox - Total=").append(noProcessed) StringBuilder msgreturn = new StringBuilder("processInBox - Total=").append(noProcessed)
@ -178,13 +201,14 @@ public class RequestEMailProcessor extends SvrProcess
// Session // Session
Properties props = System.getProperties(); Properties props = System.getProperties();
props.put("mail.store.protocol", "smtp"); props.put("mail.store.protocol", "imap");
props.put("mail.transport.protocol", "smtp"); props.put("mail.transport.protocol", "imap");
props.put("mail.host", p_IMAPHost); props.put("mail.host", p_IMAPHost);
props.put("mail.smtp.auth","true"); props.put("mail.imap.port", p_IMAPPort);
EMailAuthenticator auth = new EMailAuthenticator (p_IMAPUser, p_IMAPPwd); EMailAuthenticator auth = new EMailAuthenticator (p_IMAPUser, p_IMAPPwd);
// //
m_session = Session.getDefaultInstance(props, auth); m_session = Session.getInstance(props, auth);
m_session.setDebug(CLogMgt.isLevelFinest()); m_session.setDebug(CLogMgt.isLevelFinest());
if (log.isLoggable(Level.FINE)) log.fine("getSession - " + m_session); if (log.isLoggable(Level.FINE)) log.fine("getSession - " + m_session);
return m_session; return m_session;
@ -204,7 +228,10 @@ public class RequestEMailProcessor extends SvrProcess
throw new IllegalStateException("No Session"); throw new IllegalStateException("No Session");
// Get IMAP Store // Get IMAP Store
m_store = m_session.getStore("imap"); if (p_IMAPHost.startsWith("imap.gmail.com"))
m_store = m_session.getStore("imaps");
else
m_store = m_session.getStore("imap");
// Connect // Connect
m_store.connect(); m_store.connect();
// //
@ -227,7 +254,7 @@ public class RequestEMailProcessor extends SvrProcess
// Open Inbox // Open Inbox
Folder inbox = folder.getFolder(p_InboxFolder); Folder inbox = folder.getFolder(p_InboxFolder);
if (!inbox.exists()) if (!inbox.exists())
throw new IllegalStateException("No Inbox"); throw new AdempiereException ("Wrong inbox name : " + p_InboxFolder);
inbox.open(Folder.READ_WRITE); inbox.open(Folder.READ_WRITE);
if (log.isLoggable(Level.FINE)) log.fine("processInBox - " + inbox.getName() if (log.isLoggable(Level.FINE)) log.fine("processInBox - " + inbox.getName()
+ "; Messages Total=" + inbox.getMessageCount() + "; Messages Total=" + inbox.getMessageCount()
@ -236,7 +263,7 @@ public class RequestEMailProcessor extends SvrProcess
// Open Request // Open Request
Folder requestFolder = folder.getFolder(p_RequestFolder); Folder requestFolder = folder.getFolder(p_RequestFolder);
if (!requestFolder.exists() && !requestFolder.create(Folder.HOLDS_MESSAGES)) if (!requestFolder.exists() && !requestFolder.create(Folder.HOLDS_MESSAGES))
throw new IllegalStateException("Cannot create Request Folder"); throw new AdempiereException ("Cannot create request folder : " + p_RequestFolder);
requestFolder.open(Folder.READ_WRITE); requestFolder.open(Folder.READ_WRITE);
// Open Workflow // Open Workflow
@ -248,7 +275,7 @@ public class RequestEMailProcessor extends SvrProcess
// Open Error // Open Error
Folder errorFolder = folder.getFolder(p_ErrorFolder); Folder errorFolder = folder.getFolder(p_ErrorFolder);
if (!errorFolder.exists() && !errorFolder.create(Folder.HOLDS_MESSAGES)) if (!errorFolder.exists() && !errorFolder.create(Folder.HOLDS_MESSAGES))
throw new IllegalStateException("Cannot create Error Folder"); throw new AdempiereException ("Cannot create Error Folder : " + p_ErrorFolder);
errorFolder.open(Folder.READ_WRITE); errorFolder.open(Folder.READ_WRITE);
// Messages // Messages
@ -284,6 +311,8 @@ public class RequestEMailProcessor extends SvrProcess
Message[] deleted = inbox.expunge(); Message[] deleted = inbox.expunge();
noRequest++; noRequest++;
} else {
noError++;
} }
} catch (Exception e) { } catch (Exception e) {
if (log.isLoggable(Level.INFO)) log.info("message " + hdrs[0] + " threw error"); if (log.isLoggable(Level.INFO)) log.info("message " + hdrs[0] + " threw error");
@ -344,20 +373,27 @@ public class RequestEMailProcessor extends SvrProcess
} }
// Message-ID as documentNo // Message-ID as documentNo
String[] hdrs = msg.getHeader("Message-ID"); String[] hdrs = msg.getHeader("Message-ID");
// set DocumentNo
int maxlen = MColumn.get(getCtx(), MRequest.Table_Name, MRequest.COLUMNNAME_DocumentNo).getFieldLength();
String documentNo = hdrs[0];
if (documentNo.startsWith("<") && documentNo.endsWith(">"))
documentNo = documentNo.substring(1, documentNo.length()-1);
if (documentNo.length() > maxlen)
documentNo = documentNo.substring(0,30);
// Review if the e-mail was already created, comparing Message-ID+From+body // Review if the e-mail was already created, comparing Message-ID+From+body
int retValuedup = 0; int retValuedup = 0;
String sqldup = "select r_request_id from r_request " String sqldup = "SELECT R_Request_ID FROM R_Request "
+ "where ad_client_id = ? " + "WHERE AD_Client_ID = ? "
+ "and documentno = ? " + "AND DocumentNo = ? "
+ "and startdate = ?"; + "AND StartDate = ?";
PreparedStatement pstmtdup = null; PreparedStatement pstmtdup = null;
ResultSet rsdup = null; ResultSet rsdup = null;
try try
{ {
pstmtdup = DB.prepareStatement (sqldup, null); pstmtdup = DB.prepareStatement (sqldup, null);
pstmtdup.setInt(1, getAD_Client_ID()); pstmtdup.setInt(1, getAD_Client_ID());
pstmtdup.setString(2, hdrs[0].substring(0,30)); pstmtdup.setString(2, documentNo);
pstmtdup.setTimestamp(3, new Timestamp(msg.getSentDate().getTime())); pstmtdup.setTimestamp(3, new Timestamp(msg.getSentDate().getTime()));
rsdup = pstmtdup.executeQuery (); rsdup = pstmtdup.executeQuery ();
if (rsdup.next ()) if (rsdup.next ())
@ -436,8 +472,7 @@ public class RequestEMailProcessor extends SvrProcess
msgreq = new StringBuilder("FROM: ") .append(from[0].toString()).append("\n").append(getMessage(msg)); msgreq = new StringBuilder("FROM: ") .append(from[0].toString()).append("\n").append(getMessage(msg));
req.setResult(msgreq.toString()); req.setResult(msgreq.toString());
// Message-ID as documentNo // Message-ID as documentNo
if (hdrs != null) req.setDocumentNo(documentNo);
req.setDocumentNo(hdrs[0].substring(0,30));
// Default request type for this process // Default request type for this process
if (R_RequestType_ID > 0) if (R_RequestType_ID > 0)
@ -528,9 +563,8 @@ public class RequestEMailProcessor extends SvrProcess
String disposition = part.getDisposition(); String disposition = part.getDisposition();
if ((disposition != null) && if ( disposition != null
((disposition.equals(Part.ATTACHMENT) || && (disposition.equalsIgnoreCase(Part.ATTACHMENT) || disposition.equalsIgnoreCase(Part.INLINE))) {
(disposition.equals(Part.INLINE))))) {
MAttachment attach = req.createAttachment(); MAttachment attach = req.createAttachment();

View File

@ -211,8 +211,7 @@ public class MPInstance extends X_AD_PInstance
MRole role = MRole.get(getCtx(), AD_Role_ID); MRole role = MRole.get(getCtx(), AD_Role_ID);
Boolean access = role.getProcessAccess(AD_Process_ID); Boolean access = role.getProcessAccess(AD_Process_ID);
if (access == null || !access.booleanValue()) if (access == null || !access.booleanValue())
throw new IllegalAccessError("Cannot access Process " + AD_Process_ID throw new IllegalAccessError(Msg.getMsg(getCtx(), "CannotAccessProcess", new Object[] {AD_Process_ID, role.getName()}));
+ " with role: " + role.getName());
} }
super.setAD_Process_ID (AD_Process_ID); super.setAD_Process_ID (AD_Process_ID);
} // setAD_Process_ID } // setAD_Process_ID

View File

@ -2581,11 +2581,14 @@ public final class MRole extends X_AD_Role
while (rs.next()) { while (rs.next()) {
String op = rs.getString(1); String op = rs.getString(1);
String active=rs.getString(2); String active=rs.getString(2);
if ("N".equals(active) && validOptions.contains(op)) { if ("N".equals(active)) {
validOptions.remove(op); if (validOptions.contains(op)) {
validOptions.remove(op);
}
} else { } else {
if (!validOptions.contains(op)) if (!validOptions.contains(op)) {
validOptions.add(op); validOptions.add(op);
}
} }
} }
} }

View File

@ -926,7 +926,7 @@ public class MUser extends X_AD_User
} }
} }
if (newRecord || is_ValueChanged("Password")) { if (getPassword() != null && getPassword().length() > 0 && (newRecord || is_ValueChanged("Password"))) {
// Validate password policies / IDEMPIERE-221 // Validate password policies / IDEMPIERE-221
if (get_ValueOld("Salt") == null && get_Value("Salt") != null) { // being hashed if (get_ValueOld("Salt") == null && get_Value("Salt") != null) { // being hashed
; ;