IDEMPIERE-2928 Save Web Services User Agent in Session Description / IDEMPIERE-2929 Web Services Response BinaryData

This commit is contained in:
sauljabin 2015-11-11 10:52:54 -05:00
parent 447a497718
commit a0c86233fc
3 changed files with 23 additions and 7 deletions

View File

@ -279,6 +279,9 @@ public class CompiereService {
session = MSession.get (getCtx(), true);
}
session.setWebSession("WebService");
session.setDescription(session.getDescription() + "\nUser Agent: " + getCtx().getProperty("#UserAgent"));
session.saveEx();
m_loggedin = true;

View File

@ -41,6 +41,7 @@ import javax.jws.WebService;
import javax.xml.namespace.QName;
import javax.xml.ws.WebServiceContext;
import org.apache.commons.codec.binary.Base64;
import org.apache.cxf.jaxrs.ext.MessageContext;
import org.apache.xmlbeans.StringEnumAbstractBase.Table;
import org.compiere.model.I_AD_Column;
@ -1391,10 +1392,13 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
String columnName = poinfo.getColumnName(i);
if (m_webservicetype.isOutputColumnNameAllowed(columnName)) {
DataField dfid = dr.addNewField();
dfid.setColumn(columnName);
if (po.get_Value(i) != null)
dfid.setVal(po.get_Value(i).toString());
else
dfid.setColumn(columnName);
if (po.get_Value(i) != null){
if(po.get_Value(i) instanceof byte[]){
dfid.setVal(new String(Base64.encodeBase64((byte[]) po.get_Value(i))));
}else
dfid.setVal(po.get_Value(i).toString());
}else
dfid.setVal(null);
}
}
@ -1538,10 +1542,13 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
DataRow dr = ds.addNewDataRow();
for (int i = 0; i < poinfo.getColumnCount(); i++) {
String columnName = poinfo.getColumnName(i);
if (m_webservicetype.isOutputColumnNameAllowed(columnName)) {
if (m_webservicetype.isOutputColumnNameAllowed(columnName)) {
DataField dfid = dr.addNewField();
dfid.setColumn(columnName);
dfid.setVal(rsquery.getString(columnName));
if(rsquery.getObject(columnName) instanceof byte[])
dfid.setVal(new String(Base64.encodeBase64(rsquery.getBytes(columnName))));
else
dfid.setVal(rsquery.getString(columnName));
}
}
}

View File

@ -119,6 +119,8 @@ public class AbstractService {
Env.setContext(m_cs.getCtx(), "#AD_User_ID", user.getAD_User_ID() );
Env.setContext(m_cs.getCtx(), "#AD_User_Name", user.getName() );
Env.setContext(m_cs.getCtx(), "#SalesRep_ID", user.getAD_User_ID() );
String userAgent = getHttpServletRequest().getHeader("User-Agent");
Env.setContext(m_cs.getCtx(), "#UserAgent", userAgent == null ? "Unknown" : userAgent);
}
KeyNamePair[] roles = login.getRoles(loginRequest.getUser(), selectedClient);
@ -331,7 +333,11 @@ public class AbstractService {
OutputField outField= outputFields.addNewOutputField();
outField.setColumn(colName);
if(po.get_Value(indCol)!=null){
outField.setValue(po.get_Value(indCol).toString());
if(po.get_Value(indCol) instanceof byte[])
outField.setValue(new String(Base64.encodeBase64((byte[]) po.get_Value(indCol))));
else
outField.setValue(po.get_Value(indCol).toString());
Lookup lookup = poInfo.getColumnLookup(indCol);
if(lookup != null){
//Setting text