Upload
jared-ottley
View
881
Download
5
Embed Size (px)
DESCRIPTION
Alfresco Summit 2013 Presentation by Jared Ottley and Will Abson. Discuss how the Alfresco for Salesforce Integration works; How to get and install the integration; Challenges; ideas for for future releases.
Citation preview
#SummitNow
Alfresco for Salesforce5 November 2013 / 13 November 2013
Will Abson ([email protected])Jared Ottley ([email protected])Gregory Melahn ([email protected])
#SummitNow
•Part One (Business)o Overview and Demonstration
•Part Two (Technical)o How it Workso Building on Salesforceo Building on Alfresco
Agenda
#SummitNow
Part One
#SummitNow
What does the App do?
• Allows Salesforce Users to attach Documents to Salesforce Objects and have them stored in Alfrescoo Four Specific Salesforce Object Types supported
▪ Accounts▪ Cases▪ Contracts▪ Opportunities
• Allows Salesforce Users to Edit, View and Delete the attached Alfresco Documents
• Creates Chatter about the Alfresco Documents
#SummitNow
Finding the App
•Go to the Salesforce App Exchangeo https://
appexchange.salesforce.com/
•Enter some search criteria (e.g. ‘Alfresco’)
#SummitNow
The App Exchange Listing
#SummitNow
Installing the App
#SummitNow
Demo
#SummitNow
Demo
#SummitNow
Part Two
#SummitNow
Alfresco and SF Components
Alfresco Repository Salesforce
Salesforce Model Sample Layouts
Alfresco Share
Adv. Search Form
Properties Config
Security Profiles
VisualForce Pages
Apex Classes
#SummitNow
Salesforce Model
Salesforce RecordSalesforce Attachment
CRM Account
CRM Case
CRM Contract
CRM Opportunity
Document Type
1 0..N
Stored in <site>/Salesforce Records Stored in <site>/documentLibrary/Salesforce
Attachments
Assoc
Additional Aspects
#SummitNow
Application Packaging
On the Salesforce sideo (??)o Deployed on the AppExchange
On the Alfresco side (MyAlfresco only)o Repo AMP
▪ salesforce-repo-1.0.0.ampo Share AMP
▪ salesforce-share-1.0.0.amp
#SummitNow
How it Works
API: O
Auth
+
CMIS
Salesforce Users
Web browser
#SummitNow
How it Works
API: O
Auth
+
CMIS
Salesforce Users
Web browser
Upload:OAuth + CORS +CMIS
#SummitNow
How it Works - Downloading a File
OAut
h +
CMIS
Salesforce Users Web browser
1. User clicks Download link for a file
2. Salesforce-side code checks the user’s access token is still valido If not valid, the token
is refreshed3. Salesforce-side code
checks the document is present in Alfresco, providing nodeRefo If not present, the
user is forwarded to a ‘page not found’ page
4. Salesforce-side code access the content of the file from Alfresco Cloud via CMIS and streams it back to the user
#SummitNow
How it Works - Uploading a File
OAut
h +
CMIS
Salesforce Users Web browser
OAuth + CORS +CMIS
1. User clicks Attach File button in their browser, taken to New Document page
2. User selects file, enters Document Name and Document Type (drop-down) and hits Save
3. Page fires off POST request to trigger Apex remote action in Salesforce-side code, which creates empty content item in the Document Library
4. Browser does a CMIS PUT directly against Alfresco Cloud to upload the content itselfo This works around
Salesforce request body size restrictions
o Access token from Salesforce is re-used
#SummitNow
Cloud Sync
Firewall
Corporate Users
Remote Office
Syn
cO
Auth
+
CMIS
Salesforce Users
Web browser
OAuth + CORS +CMIS
#SummitNow
Building on Salesforce
*Does not include SOAP and REST APIs
Apex Visualforce
#SummitNow
CMIS API Challenges
#SummitNow
CMIS API Challenges - No CMIS Client• Force.com has no concept of libraries
• Install packages from appexchange• Limited to what to is exposed by developer
• Add classes from other projects• Count against you code total
• No one has written a CMIS appexchange package• No one has written CMIS classses that could be added
• Apex Web Callouts to CMIS endpoints• Governance Limits• Installer must approve connecting endpoints
#SummitNow
CMIS API Challenges - Tenant Id
• Calls to Cloud CMIS API need tenant id• CMIS provides no way to discover tenant id
• Two options:• User provides• Use REST API
• https://api.alfresco.com• Apex JSON parser (requires new classes)
• JSON objects: Reserved words• Limit to home network or ask user input
#SummitNow
CMIS API Challenges - Verbosity
• CMIS is Verbose!• Can reduce a little using filters
• Governance Limits
Example: Alfresco.com• Alfresco.com site list is 400+ (and growing)• Document size is 2.5 MB
Options:• Paging• CMIS Browser Bindings
#SummitNow
CMIS API Challenges - Parsing XML
• Apex XML parser
Gotcha: DateTime
String dateString = property.getChildElement('value', CMIS_NS).getText();
dateString = dateString.replace('T', ' ');
dateString= dateString.substring(0, dateString.length() - 6);
relatedDoc.creationDate = DateTime.valueOf(dateString);
#SummitNow
CMIS API Challenges - Child Objects
• Lacks support for including child objects
If it did….
Governance Limit Heap Size
Since it doesn’t…
Governance Limit Callout Requests
#SummitNow
CMIS API Challenge - Delete
CMIS API allows delete of relationship using objectId
using: https://api.alfresco.com/alfresco.com/public/cmis/versions/1.0/atom/entry?id=assoc:4240216&allVersions=true
Relationship MAY be deleted when the target is removed in a peer relationship (according to the spec).
Any code should allow for a 404.
Previously the relationship remained and target pointed to the archiveStore.
#SummitNow
CMIS API Challenges – Secondary Types
•Lack of support of secondary types makes the the integration dependent on Alfresco extensions.
•Secondary type support would allow client to fallback to base type.
#SummitNow
CMIS API Challenges - Sites folder
Listing documents is achieved using a CMIS getObjectByPath call•We know the path of the Salesforce Record item - /Sites/<network-id>/Salesforce Records/<record-id>
But, the Sites folder may not always be named 'Sites', e.g. 'Sitios'!
•CMIS does not provide a way to specify a QName path, rather than a name path.
So, we must find out what the sites folder is called, and store this
•This is done when the user selects the site to be used for document storage.
#SummitNow
CMIS Workbench as Node Browser
org.apache.chemistry.opencmis.binding.spi.type=atompub
org.apache.chemistry.opencmis.binding.atompub.url=https://api.alfresco.com/cmis/versions/1.0/atom
org.apache.chemistry.opencmis.binding.auth.http.basic=false
org.apache.chemistry.opencmis.binding.header.0=Authorization:Bearer <oauth token>
org.apache.chemistry.opencmis.binding.compression=true
cmis.workbench.folder.includeAcls=false
cmis.workbench.object.includeAcls=false
cmis.workbench.version.includeAcls=false
#SummitNow
Salesforce Governance
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm
10 Total number of callouts (HTTP requests or Web services calls) in a transaction
6 MB Total heap size
10,000 milliseconds
Maximum CPU time on the Salesforce servers
5 MB File size limit
#SummitNow
Security Considerations
Salesforce apply strict criteria to apps before they can be publicly listed on the AppExchange
Partnership with Checkmarx to allow developers to check for common vulnerabilities in their Apex / Visualforce apps
The AppExchange team are responsible for performing a final check across your app and any supporting services
For Alfresco this covered the MyAlfresco service
Developers do not have access to the tools used
This feedback process takes (up to) 8 weeks
#SummitNow
Future Ideas
Access Salesforce Content from Alfresco
Salesforce Chatter API (plug)
Avoiding Salesforce Governance limits
Salesforce Canvas Framework
Alfresco Embed
#SummitNow
Add permission set to multiple users
Every user must have the ‘Alfresco Cloud Document Management User’ permission set applied to their account.
This can be scripted through the Salesforce Developer Console.
#SummitNow
Example
User u = [select id from User where <logic here>];
PermissionSet ps = [Select p.Id From PermissionSet p where p.label = 'Alfresco Cloud Document Management User'];
PermissionSetAssignment psa = new
PermissionSetAssignment(AssigneeId = u.id, PermissionSetId = ps.id);
insert psa;
#SummitNow
More information
Documentationhttps://appexchange.salesforce.com/servlet/servlet.FileDownload?
file=00P3000000Hd94DEAR
Salesforce App Exchange Listinghttps://appexchange.salesforce.com/listingDetail?
listingId=a0N3000000B34XIEAZ
#SummitNow
#SummitNow
Known Issues and Limits
• We don’t support IE versions prior to IE 10
• Maximum of number of documents that can be attached to a single Salesforce item is 100
• Documents start out as V1.1, not 1.0
• If you attach a document with the same name as an existing attachment to the same Salesforce Object, we name the attachment with a ‘-<n>’ suffix (up to three such attachments)
• Uploading a document that exceeds the Alfresco quota will fail, but a Salesforce Chatter entry will still be created (transactional integrity)
• The app uses the name of the Salesforce object to create the name of the folder in Alfresco where the files are uploaded. If you create two Salesforce objects with the same name, files attached to either object will be stored in the same folder
• Moderated sites that the Salesforce Admin is not yet a member of will still appear in the Sites dropdown
#SummitNow
Force.com Limitations
No local deployment process, deploy process is via an external API with only an Ant task to integrate this into your workflow
NamespacingFormats not well documentedThe process of certifying an app is opaque and non-trivial