How to pull all available query fields for an SOQL object? - salesforce

So, I'm seeing Stackoverflow is more responsive than the actual Salesforce community and I'm reposting my question from here:
How can I pull a list of all of the available query fields for an SOQL object? I have my DataLoader script ready to go, but I need a way to pull all the query fields for specific SOQL data objects and feed them into my process-conf.xml file in DataLoader to pull the values of all those fields to a separate location. I have the DataLoader value pulling already setup, but I need a way to get all the available query fields as they continue to change. The ANT Migration Tool does not appear to be able to pull the query fields itself.
ANT Tool configuration:
# build.properties
# Specify the login credentials for the desired Salesforce organization
sf.username = <test user acct>
sf.password = <password>
#sf.sessionId = <Insert your Salesforce session id here. Use this or username/password above. Cannot use both>
#sf.pkgName = <Insert comma separated package names to be retrieved>
#sf.zipFile = <Insert path of the zipfile to be retrieved>
#sf.metadataType = <Insert metadata type name for which listMetadata or bulkRetrieve operations are to be performed>
sf.serverurl = https://na3.salesforce.com
sf.maxPoll = 20
# If your network requires an HTTP proxy, see http://ant.apache.org/manual/proxy.html for configuration.
#
logType=Detail
build.xml
<project name="Sample usage of Salesforce Ant tasks" default="test" basedir="." xmlns:sf="antlib:com.salesforce">
<property file="build.properties"/>
<property environment="env"/>
<!-- Setting default value for username, password and session id properties to empty string
so unset values are treated as empty. Without this, ant expressions such as ${sf.username}
will be treated literally.
-->
<condition property="sf.username" value=""> <not> <isset property="sf.username"/> </not> </condition>
<condition property="sf.password" value=""> <not> <isset property="sf.password"/> </not> </condition>
<condition property="sf.sessionId" value=""> <not> <isset property="sf.sessionId"/> </not> </condition>
<taskdef resource="com/salesforce/antlib.xml" uri="antlib:com.salesforce">
<classpath>
<pathelement location="ant-salesforce.jar" />
</classpath>
</taskdef>
<!-- See what happens here -->
<target name="retrieveSOQL">
<sf:retrieve
username="${sf.username}"
password="${sf.password}"
sessionId="${sf.sessionId}"
serverurl="${sf.serverurl}"
retrieveTarget="output"
unpackaged="package.xml"/>
</target>
</project>
Package.xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>Account</members>
<members>Opportunity</members>
<members>Lead</members>
<members>Event</members>
<members>Project__c</members>
<name>CustomObject</name>
</types>
<version>41.0</version>
</Package>
process-conf.xml
<beans>
<bean id="AccountExtract"
class="com.salesforce.dataloader.process.ProcessRunner"
singleton="false">
<description>csvAccountExtract job</description>
<property name="name" value="csvAccountExtract"/>
<property name="configOverrideMap">
<map>
<entry key="sfdc.debugMessages" value="false"/>
<entry key="sfdc.debugMessagesFile" value="C:\Users\user\Desktop\salesforce_backup\sfdcSoapTrace.log"/>
<entry key="sfdc.endpoint" value="https://na3.salesforce.com"/>
<entry key="sfdc.username" value="<username>"/>
<!-- password below has been encrypted using key file, therefore it will not work without the key setting: process.encryptionKeyFile
the password is not a valid encrypted value, please generate the real value using encrypt.bat utility -->
<entry key="sfdc.password" value="<password>"/>
<entry key="process.encryptionKeyFile" value="key.txt"/>
<entry key="sfdc.timeoutSecs" value="600"/>
<entry key="sfdc.loadBatchSize" value="200"/>
<entry key="sfdc.entity" value="Account"/>
<entry key="sfdc.extractionRequestSize" value="500"/>
<entry key="sfdc.extractionSOQL" value="Select Id, IsDeleted, MasterRecordId, Name, Type, RecordTypeId, ParentId, BillingStreet FROM Account"/>
<entry key="process.operation" value="extract"/>
<entry key="dataAccess.type" value="csvWrite"/>
<entry key="dataAccess.name" value="C:\Users\user\Desktop\account.csv"/>
</map>
</property>
</bean>
...
</beans>

Related

MDB not persisting data in sql server

I have MDB configured to receive incoming message and persist it via a SLSB using JPA (eclipseLink). The database inserts work for one off message but in load conditions (3 or 4 messages per second), Data is not persisted in DB. I can see sql Insert queries in the log but no data in DB.
Persistence File:
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<!-- <persistence-unit name="mainPU" transaction-type="JTA"> -->
<persistence-unit name="mainPU" transaction-type="JTA">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<jta-data-source>ecpcPool</jta-data-source>
<class>com.fc.ECP.domain.Address</class>
<class>com.fc.ECP.domain.Customer</class>
<class>com.fc.ECP.domain.DocumentationSignature</class>
<class>com.fc.ECP.domain.EcpSystem</class>
<class>com.fc.ECP.domain.EcpTransaction</class>
<class>com.fc.ECP.domain.EcpWkflw</class>
<class>com.fc.ECP.domain.EidVerify</class>
<class>com.fc.ECP.domain.EsignDetail</class>
<class>com.fc.ECP.domain.Finpln</class>
<class>com.fc.ECP.domain.FinplnDocumentation</class>
<class>com.fc.ECP.domain.ThirdPartyCrdntl</class>
<class>com.fc.ECP.domain.ThirdPartyDocumentation</class>
<class>com.fc.ECP.domain.TransactionType</class>
<class>com.fc.ECP.domain.Advice</class>
<class>com.fc.ECP.domain.Advcln</class>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<shared-cache-mode>NONE</shared-cache-mode>
<properties>
<property name="eclipselink.target-server" value="WebLogic_10"
/>
<property name="javax.persistence.jtaDataSource"
value="ecpcPool" />
<!-- <property name="javax.persistence.jtaDataSource"
value="jdbc/MicrosoftSQLServer"/> -->
<!-- <property name="javax.persistence.jtaDataSource"
value="ecp_prx_ds"/> -->
<property name="eclipselink.target-database"
value="org.eclipse.persistence.platform.database.SQLServerPlatform" />
<property name="eclipselink.session.customizer"
value="com.fc.adr.jpa.JPASessionCustomizer" />
<property name="com.fc.adr.jpa.schema" value="$(mainPU.schema)"
/>
<property name="com.fc.adr.jpa.schema.sequences"
value="$(mainPU.schema.sequences)" />
<property name="eclipselink.logging.logger"
value="DefaultLogger" />
<property name="eclipselink.logging.level.sql" value="FINE" />
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.logging.parameters" value="true" />
<property name="eclipselink.persistence-context.flush-mode"
value="commit" />
</properties>
</persistence-unit>
</persistence>
Switch to EJB2 style config for MDB.
Underlying Cause:
The EJB3 style MDB ‘s methods are wrapped by CDI injection.
One of the wrapper classes in the stack trace is: com.oracle.pitchfork.intercept.MethodInvocationInvocationContext
which is in a spring framework module jar in weblogic
MethodInvocationInvocationContext looks for a WebServiceContext in the JNDI tree at “java:comp/WebServiceContext”
Having a jax-ws service puts a WebServiceContext at “java:comp/WebServiceContext”
If the WebServiceContext is present, then MethodInvocationInvocationContext tries to access its values for the MessageDrivenContext
The spec requires WebServiceContext to throw an IllegalStateException if it is accessed outside of a web service call

create a new file from payload in wso2

I am new to wso2 and working on a few POCs where i have to create a file at some location , i have looked into all vfs examples where there is always a file processed and written to a new location.
What i want to achieve is write a new file to a directory by the content i receive in a sequence.
For my requirement process i have exposed a REST service and it calls this sequence.
The sequence configuration is as follows.
<?xml version="1.0" encoding="UTF-8"?>
<sequence xmlns="http://ws.apache.org/ns/synapse" name="FileWriteSequence">
<clone>
<target>
<sequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<property name="transport.vfs.ReplyFileName" value="myOutputFile.txt" scope="transport" type="STRING"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file://D:/Tools"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
This sequence creates a file from the latest message from the REST resource but the file name is always the project name.
Whatever i try it doesnt change.
I have tried giving other proxy parameters shown below as property above my sequence as well .Instead of paramters i passed them above the property <property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
Namely :-
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://D:/Tools</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://D:/backup</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
Still no progress.
Can anyone help me here?
Regards,
Rahul.
In case anyone wants to know i have made a workaround for this i called a proxy service from my rest resource and it worked .
In my resource i called endpoint like this
<send>
<endpoint key="FileProxyEndPt"/>
</send>
Then i created a proxy service as follows
<proxy xmlns="http://ws.apache.org/ns/synapse" name="FileWriteProxy"
transports="http https vfs" startOnLoad="true" trace="enable">
<target>
<inSequence>
<clone>
<target sequence="FileWriteSequence" />
</clone>
</inSequence>
<outSequence />
<faultSequence />
</target>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file://D:/Tools</parameter>
<parameter name="transport.vfs.MoveAfterFailure">file://D:/backup</parameter>
<parameter name="transport.vfs.ContentType">text/plain; charset=ISO-8859-1</parameter>
<parameter name="transport.vfs.ActionAfterFailure">MOVE</parameter>
This way it worked it but never worked exactly in a resource.So had to take a longer route , hope somebody provides a solution which can be implemented directly.

Configuring 2 database in mybatis + springs

I have an existing setup of mybatis + springs for working with Oracle DB. I have a set of java mapper interfaces, a set of corresponding mapper xmls (each having reference to their corresponding java mapper). I need to setup support for MSSQL also, but finding it hard to do that. I have created a separate set of xmls (specific to queries of MSSQL) in com/mycomp/mob/db/mappers/mssql.
Below is the extract of my applicationConext.xml (Here DBDataSource is an internal class which reads a config files to get all DB details).
<bean name="dataSource" class="com.mycomp.mob.core.db.DBDataSource">
<constructor-arg index="0" name="dbAlias" value="mob" />
<constructor-arg index="1" name="cfgSection" value="primary" />
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.mycomp.mob.db.mappers.oracle" />
</bean>
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.mycomp.mob.db.mappers.oracle" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
Below is part of mybatis-config.xml (here ${} params are replaced using the earlier DBDatasource)
<configuration>
<typeAliases>
<package name="com.mycomp.mob.db.model" />
</typeAliases>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC" />
<dataSource type="POOLED">
<property name="driver" value="${driver}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/mycomp/mob/db/mappers/oracle/tenant.xml" />
<mapper resource="com/mycomp/mob/db/mappers/oracle/functionenty.xml" />
</mappers>
</configuration>
com.mycomp.mob.db.model contains POJO for tenant and functionentry.
Usage is as below :
ITenantMapper mappper = sqlSessionFactory.openSession().getMapper(ItenantMapper.class)
Tenant t = mapper.getTenant();
Now at a time only one DB (which is configured as primary in DB config file) will be used. So how to make sure that XML corresponding to that particular DB is invoked by the java mapper interface.
Also need to know can I configure same java mapper class name inside the mapper xmls of mssql ?
Is the flow used correct or I need to change the flow for supporting multiple databases.
Create two datasources and two SessionFactories in spring one for Oracle another for MSSQL.

cxf-rs-ws authorization under karaf

I'm trying to configure a cxf soap webservice with authorization and authentication to be deployed on Servicemix.
I configured the LDAP authentication module as follows:
<!-- Bean to allow the $[karaf.base] property to be correctly resolved -->
<ext:property-placeholder placeholder-prefix="$[" placeholder-suffix="]"/>
<jaas:config name="myRealm">
<jaas:module className="org.apache.karaf.jaas.modules.ldap.LDAPLoginModule" flags="required">
connection.url = ldap://srv-ldap:389
user.base.dn = ou=people,dc=intranet,dc=company,dc=com
user.filter = (uid=%u)
user.search.subtree = false
role.base.dn = ou=groups,dc=intranet,dc=company,dc=com
role.filter = (member:=uid=%u,ou=people,dc=intranet,dc=company,dc=com)
role.name.attribute = cn
role.search.subtree = true
authentication = simple
</jaas:module>
</jaas:config>
<service interface="org.apache.karaf.jaas.modules.BackingEngineFactory">
<bean class="org.apache.karaf.jaas.modules.properties.PropertiesBackingEngineFactory"/>
</service>
And here is the beans.xml file
<jaxws:endpoint id="myService"
implementor="com.myorg.services.impl.MyServiceWSImpl"
address="/myService">
<jaxws:inInterceptors>
<bean class="org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor">
<constructor-arg>
<map>
<entry key="action" value="UsernameToken" />
<entry key="passwordType" value="PasswordText" />
</map>
</constructor-arg>
</bean>
<ref bean="authenticationInterceptor" />
<ref bean="authorizationInterceptor" />
</jaxws:inInterceptors>
<jaxws:properties>
<entry key="ws-security.validate.token" value="false" />
</jaxws:properties>
</jaxws:endpoint>
<bean id="authenticationInterceptor"
class="org.apache.cxf.interceptor.security.JAASLoginInterceptor">
<property name="contextName" value="myRealm" />
</bean>
<bean id="authorizationInterceptor"
class="org.apache.cxf.interceptor.security.SecureAnnotationsInterceptor">
<property name="securedObject" ref="securedBean"/>
</bean>
Finally, in my WebService implementation I annotated a method with #RolesAllowed.
#RolesAllowed("Role1")
public Department get(String name) throws IdMException {
return service.get(name);
}
The authentication interceptor is retrieving the user, authenticating it and retrieving the groups as RolePrincipal instances.
Then, in the authorization interceptor (SecureAnnotationsInterceptor), the method configuration is read, the expectedRoles are "Role1", but the SimpleAuthorizingInterceptor.isUserInRole method returns false.
I haven't found any example trying to do more or less the same and the few information I found was from the CXF documentation page http://cxf.apache.org/docs/security.html#Security-Authorization
I have to be missing something important, hope somebody could help me.
Thanks in advance and kind regards.
Your problem is because of Karaf's RolePricipal do not implements Group as CXF expected. Instead of it, it implements Pricipal so CXF thinks that 1st role name is a username. That is why "SimpleAuthorizingInterceptor.isUserInRole method returns false".
A solution is to wait for fixed versions of CXF (2.7.11 and 3.0.0).
If not possible to update to newer version, then an odd and temporary solution (simply workaround) is to add more than one role to a user in LDAP and to method.
You can find more about that bug here: CXF-5603

Salesforce data loader error no such field

I am trying to build an application to export and archive data from SF. I'm trying to export data from several objects, but I'm having problems with a few of them. I'm getting errors like
6140 [Approvals__c_Export] ERROR com.salesforce.dataloader.action.progress.NihilistProgressAdapter - No such field deducted_ on entity Approvals__c
I've check and there is no such filed called 'deducted_' it's called 'Deducted_from_payment__c' and that is what the sql has as well as the mapping file.
I used the data loader gui to generate all my sql statements and they all work with the gui but if i try with the command line it fails.
I am getting the same error on other objects, and for every field it complains about there is a '_from' in the field.
I've tried putting [] around the field as well as '', with no luck.
Here is the process-conf
<bean id="Approvals__c_Export" class="com.salesforce.dataloader.process.ProcessRunner" singleton="false">
<description></description>
<property name="name" value="Approvals__c_Export"/>
<property name="configOverrideMap">
<map>
<entry key="process.outputError" value="archive\status\Approvals__c_Export_error.csv"/>
<entry key="process.outputSuccess" value="archive\status\Approvals__c_Export_success.csv"/>
<entry key="sfdc.entity" value="Approvals__c"/>
<entry key="sfdc.extractionRequestSize" value="600"/>
<entry key="sfdc.extractionSOQL" value="Select Id, OwnerId, IsDeleted, Name, RecordTypeId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, Department_Code__c, Customer_Account_Code__c, Business_Unit_Code__c, Notes_by_submitter__c, Approval_Status__c, A__c, Requested_by__c, Account_Customer__c, Customer_SO__c, Globe_Company__c, GL_Code__c, PO__c, PO_Amount_Before_Tax__c, PO_Number__c, Old_Vendor_Name__c, Invoice_or_email_attached__c, Total_Qty_of_PO_items__c, Total_PO_amount__c, PO_Complete_Attached__c, Record__c, P__c, Customer_Account__c, Date_Requested__c, New_Vendor_Name__c, Claim__c, Payment_Term__c, Vendor_Street__c, Vendor_City__c, Vendor_StateProvince__c, Vendor_Country__c, Vendor_ZIP_Postal_Code__c, Vendor_s_Invoice_Number__c, Invoice_Required_for_resolution__c, Return_Y_N__c, Claim_Reason__c, RMA_Invoice__c, Vendor_Number__c, Globe_Invoice__c, Vendor_Account_Number__c, Globe_Service_Requests__c, 'Deducted_from_payment__c', Invoice_Date__c, Actual_Invoice_Amount__c, Difference_between_approved_actual__c, Invoice_is_in_advise_A_P__c, New_approval_required__c, Customers_Cheque__c, SO_Number__c, Customer_Deduction__c, Purchase_Order__c, Origin__c, Defective_Allowance__c, Total_Excluding_Taxes__c, GST__c, PST__c, HST__c, BOL_attached__c, Delivery_Date_of_Goods__c, Payment_terms__c, Packing_Slip__c, Proof_of_Delivery_or_P_U_attached__c, Logistics_Reason__c, 'Notes_from_Finance__c', 'Notes_from_Logistics__c, Claim_ID__c, Store_Number__c, Return_Closing_Date__c, Blanket_Return_Check_Here__c, Reason_for_Return__c, D_C_Action__c, Condition_of_goods_prior_to_return__c, If_the_goods_are_to_be_returned_without__c, Who_will_be_paying_for_shipping__c, Number_of_Cases__c, Weight_in_Lbs_of_Return__c, Number_of_Pallets__c, Pallet_height__c, Address_of_pickup__c, Operations_Comments__c, RA_3__c, Sales_Plan__c, Goods_be_returned_in_master_loose__c, Repack_specifications__c, Cost_of_Transportation_CDN__c, Additional_Fees_CDN__c, Total_Returns_Domestic__c, Grand_Total_Domestic_Returns__c, DC_costs_estimate__c, DC_costs_estimate_Details__c, Department_Code2__c, Total_Claim_excluding_taxes__c, Claim_Reason_Other_Detailed_Description__c, GL_Reference_accepted__c, Pending__c, Sales_Comments__c, Logistics_Comments__c, Finance_Comments__c, PM_Comments__c, Corrective_Action_Request__c, CR__c, SC_Teams__c, GL_Reference_balance__c, Claim_Value_Accepted__c, Claim_Value_Balance_not_accepted__c, Tax_Schedule__c, Tax_Combined_Rate__c, Total_Claim_with_Taxes__c, Off_Invoice_Deduction_Value__c, Finance_refusal_reason__c, Date_submitted_for_approval__c FROM Approvals__c WHERE LastModifiedDate < 2012-01-01T00:00:00Z"/>
<entry key="process.operation" value="extract"/>
<entry key="process.mappingFile" value="conf\archiveSDL\Approvals__c.sdl"/>
<entry key="dataAccess.type" value="csvWrite"/>
<entry key="dataAccess.name" value="archive\data\Approvals__c_Export.csv"/>
</map>
</property>

Resources