SlideShare a Scribd company logo
1 of 62
Web Services: 
Encapsulation, Reusability, and 
Simplicity 
#CSUC14 
Presented by 
Wing Ming Chan, September 16, 2014 
Upstate Medical University 
chanw@upstate.edu 
1
Topics 
 Encapsulation: data and data manipulation 
hiding 
 Usernames and passwords 
 Creating phantom entities in Cascade 
 Fully qualified identifiers 
 Reusability: code ready to use without 
modification 
 AssetOperationHandlerService 
 Asset and Property classes 
 Simplicity: lines of code 
 Cascade and AssetTree classes 
 CascadeInstances and Report classes 2
Part 0: Three Questions 
3
Purposes 
 Look for positive answers 
 Reveal the problems 
 Highlight the main issues 
4
Question 1 
 How many of you can write a web service 
program, doing something, anything, without 
hard-coding the username and password 
anywhere in your code? 
 Main concern 
 Security and encapsulation of sensitive data 
 Access restrictions 
5
Question 2 
 How many of you can work with the first node of 
the second multiple field in a data definition 
block, without looking at the read dump of the 
block? Can you hard-code the location of the node 
in you program? 
 Main concern 
 Encapsulation and reusability 6
Locating Nodes 
7
Question 3 
 Besides the use of require_once or 
include_once, how many of you can use a 
single semi-colon in your code to do the following: 
 Associate metadata set 1 with all folders in a site 
(including Base Folder) 
 Associate metadata set 2 with all files in the site 
 Associate metadata set 3 with all symlinks in the site 
 Requirements: no program-specific data allowed 
in the required/included files; all information 
related to metadata sets, folders, files, and 
symlinks must show up in your code 
 Main concerns 
 Reusability and simplicity 
8
Part 1: Encapsulation 
9
The Typical Way of 
Starting a Program 
10
Problems? 
 Programs are tied with usernames, passwords, 
and WSDL URL’s 
 People can come and go 
 Changes of passwords 
 URL’s can change too (different instances) 
 Passwords exposed 
 Security 
 A single program used by multiple users 
 Usernames and passwords change depending on the 
users using the same program 
 Access restrictions 
11
Phantom: Episode I 
 Detachment of structuredData from 
dataDefinition in web services 
 Created by web services 
 Only affects data definition blocks (including those 
plugged into pages) 
 Can be created in pages, but haven’t figure out a way 
to reveal the hidden content 
12
Data Definitions 
13
Data Definition Blocks 
14
REPLACING STRUCTUREDDATA 
15
Results 
16
Hidden Multiple Nodes 
17
Results 
18
The Other Side of the Same Coin I 
19
The Other Side of the Same Coin II 
20
Creating a Java Error 
21
A NIGHTMARE… 
22 
 Pretend that I am you enemy 
 What I can do to you: 
 Detachment of data definitions from content types 
 Assigning an empty string to a checkbox in data 
definition blocks 
 Data definition manipulation with phantom nodes 
 How long will it take to solve the problem: Days? 
Weeks?
Encapsulating Usernames and 
Passwords: a Two-Step Approach 
 Step 1: move usernames and passwords out of 
programs to authentication files 
 Step 2: hide usernames and passwords from the 
system altogether 
23
Moving Usernames and Passwords 
Out of Programs: 
Using Authentication Files 
24
Authentication File Example 
25
Password-Protected Page 
26
Using Session 
27
Using Command-Prompt Arguments 
28
Authentication File: 
Entry Point to Code Library 
29
The AssetOperationHandlerService 
Class: Encapsulating Operations 
 Encapsulation 
 Username and password 
 URL 
 The SoapClient object and all operations 
 All parameters required for operations 
 The instance $service: 
 Instantiated in the authentication files 
 Passed from client code to code library 
 Performs all basic operations in code library 
30
Fully Qualified Identifiers 
 When working with data definition blocks or 
pages, we need to work with nodes 
 A fully qualified identifier of a node is the full 
path of the node, including all the information 
about ancestors and absolute position 
 Example: pie;1;pie-is-sliced 
31
What Is Special About 
Fully Qualified Identifiers 
 Example: pie;1;pie-is-sliced 
 The ;1 part following an identifier indicates that 
the field is a multiple field 
 ;0 means that the node bearing this identifier is 
the first node in the set; ;1 means that the node 
is the second node of the set 
 Unlike array indexes, the fully qualified 
identifier of a node never changes, no matter how 
many cousins and siblings it has 
 A more complicated example: main-field; 
group;2;sub-group;1;text;3 
32
Why Fully Qualified Identifiers? 
 They never change: can be hard-coded in 
programs 
 Easy node look-up 
 Possible to use for and foreach loops 
 Encapsulation of arrays and stdClass objects 
33
DATADEFINITIONBLOCK::GETIDENTIF 
IERS 
34
Part 2: Reusability 
35
Why OOP? 
 Encapsulation 
 Hiding complicated program logic 
 Hiding data and raw data structures 
 Reusability 
 The entire library consists of reusable code 
 Easy object retrieval 
 Providing look-up mechanism 
 Setting and editing data and metadata, and 
preventing unacceptable input 
 Error checking and exception handling 
 Inheritance 
 Problems with web services 36
Problems with Web Services I 
 It is possible to delete the value of a required 
field using web services (e.g. in a metadata set) 
 Cascade won’t complain when an unacceptable 
boolean value is assigned to a field (e.g. fals 
instead of false) 
 An unacceptable boolean value is ignored 
 Unlike dateTime (which is represented by an object) 
 Cascade won’t complain when an unacceptable 
string value is assigned to a dropdown 
 An undefined item is introduced 
 An empty string will also work 
37
Problems with Web Services II 
 When a single-item checkbox is assigned an 
empty string, Cascade won’t complain 
 However, the associated data definition block 
cannot be viewed (a Java error) 
 The field should have been assigned the string 
‘::CONTENT-XML-CHECKBOX::’ instead 
 Phantoms we have met 
38
Problems with Web Services III 
 Assignment of NULL vs. unset 
When modifying temporal settings for scheduled 
publishing (for a site, a publish set, or a destination), 
assignments of the NULL value to properties won’t 
work 
 Instead, we must unset the properties 
39
ASSET AND PROPERTY 
 Asset: an abstract class 
 Other abstract subclasses: ContainedAsset, 
Container, Block, Format, etc. 
 42 concrete classes corresponding to 42 asset 
types defined in the WSDL 
 All methods have returned values 
Method chaining possible 
 stdClass objects within an asset are 
represented by subclasses of Property 
40
Inheritance 
 Reusability 
 An asset class can be reused to deal with any assets 
of the same type 
Metadata-related classes can be reused in File, 
Page, Block (and its subclasses), Format (and its 
subclasses) and Symlink 
Members in a parent class inherited by child classes, 
avoiding repetition of code 
 Separate code files 
 Less code per file 
 Easier to maintain 
41
Exception Handling 
 All classes throw exceptions of various types 
 Client code is expected to deal with exceptions 
 Two modes of execution: strict and lenient 
 To throw or not to throw? Cascade::getAsset 
vs. Cascade::getX (e.g. Cascade::getPage) 
42
Part 3: Simplicity 
43
Writing Client Code 
 Client code does not look like ‘normal’ Cascade 
web service code 
 No username and password 
 No arrays of raw data or stdClass objects 
 Chained method calls 
 Handling of exceptions 
 A lot shorter: simplicity! 
 Normally, no use of new keyword 
 Easy retrieval of asset objects 
 Easy retrieval of associated objects of pages 
 High level classes: Cascade and AssetTree 44
Retrieving an Asset Object 
45
Dumping an Asset Object 
46
Working With 
A Data Definition Block 
47
Displaying Page-Related Information 
48
Setting Access Rights 
49
Setting Content Type 
50
Switch Content Type 
51
ASSETTREE 
 A tree structure consisting of: 
 Root container 
 Children 
 Sub-trees 
 What it is good for: 
 Creating reports 
 Modifying assets of a certain type or types 
 The AssetTree::traverse method 
 Visits the root, every children of the root, and recursively all 
sub-trees (depth-first traversal) 
 Accepts global functions, parameters, and results array 
(passed in by reference) 
 Global functions as filters 52
ASSETTREE::TRAVERSE 
53
ASSETTREE::APPLYFUNCTIONSTOCHIL 
D 
54
MetadataSet Associations 
55
Global Function Used 
56
Publishing Every Page in a Folder 
57
AssetTree Recipes 
58
Phantom: Episode II 
 Detachment of structuredData from 
dataDefinition in web services 
 Created by changes of data definitions 
 Affects web services only 
59
CascadeInstances: 
The Ultimate Test for Simplicity 
60
REPORT: 
ENCAPSULATING ASSETTREE 
61
Questions? 
 Tutorial: http://www.upstate.edu/cascade-admin/ 
projects/web-services/ 
 Email: chanw@upstate.edu 
 A web service user group? 
62

More Related Content

What's hot

VRE Cancer Imaging BL RIC Workshop 22032011
VRE Cancer Imaging BL RIC Workshop 22032011VRE Cancer Imaging BL RIC Workshop 22032011
VRE Cancer Imaging BL RIC Workshop 22032011
djmichael156
 
Privacy-Preserving Updates to Anonymous and Confidential Database
Privacy-Preserving Updates to Anonymous and Confidential DatabasePrivacy-Preserving Updates to Anonymous and Confidential Database
Privacy-Preserving Updates to Anonymous and Confidential Database
ijdmtaiir
 

What's hot (20)

VRE Cancer Imaging BL RIC Workshop 22032011
VRE Cancer Imaging BL RIC Workshop 22032011VRE Cancer Imaging BL RIC Workshop 22032011
VRE Cancer Imaging BL RIC Workshop 22032011
 
IJSRED-V2I2P10
IJSRED-V2I2P10IJSRED-V2I2P10
IJSRED-V2I2P10
 
Oracle to vb 6.0 connectivity
Oracle to vb 6.0 connectivityOracle to vb 6.0 connectivity
Oracle to vb 6.0 connectivity
 
KNN Classification Over Semantically secure Encrypt Data
KNN Classification Over Semantically secure Encrypt DataKNN Classification Over Semantically secure Encrypt Data
KNN Classification Over Semantically secure Encrypt Data
 
LDAP Injection & Blind LDAP Injection
LDAP Injection & Blind LDAP InjectionLDAP Injection & Blind LDAP Injection
LDAP Injection & Blind LDAP Injection
 
Securely Data Forwarding and Maintaining Reliability of Data in Cloud Computing
Securely Data Forwarding and Maintaining Reliability of Data in Cloud ComputingSecurely Data Forwarding and Maintaining Reliability of Data in Cloud Computing
Securely Data Forwarding and Maintaining Reliability of Data in Cloud Computing
 
Application Hosting
Application HostingApplication Hosting
Application Hosting
 
Data Security In Relational Database Management System
Data Security In Relational Database Management SystemData Security In Relational Database Management System
Data Security In Relational Database Management System
 
IRJET- Multiple Keyword Search over Encrypted Cloud Data
IRJET- Multiple Keyword Search over Encrypted Cloud DataIRJET- Multiple Keyword Search over Encrypted Cloud Data
IRJET- Multiple Keyword Search over Encrypted Cloud Data
 
LDAP Injection & Blind LDAP Injection in Web Applications
LDAP Injection & Blind LDAP Injection in Web ApplicationsLDAP Injection & Blind LDAP Injection in Web Applications
LDAP Injection & Blind LDAP Injection in Web Applications
 
Attribute-Based Data Sharing
Attribute-Based Data SharingAttribute-Based Data Sharing
Attribute-Based Data Sharing
 
Privacy-Preserving Updates to Anonymous and Confidential Database
Privacy-Preserving Updates to Anonymous and Confidential DatabasePrivacy-Preserving Updates to Anonymous and Confidential Database
Privacy-Preserving Updates to Anonymous and Confidential Database
 
Ieeepro techno solutions 2014 ieee java project -key-aggregate cryptosystem...
Ieeepro techno solutions   2014 ieee java project -key-aggregate cryptosystem...Ieeepro techno solutions   2014 ieee java project -key-aggregate cryptosystem...
Ieeepro techno solutions 2014 ieee java project -key-aggregate cryptosystem...
 
Providing Secure Cloud for College Campus
Providing Secure Cloud for College CampusProviding Secure Cloud for College Campus
Providing Secure Cloud for College Campus
 
Lucene solrrev documentlevelsecurity_rajanimaski_final
Lucene solrrev documentlevelsecurity_rajanimaski_finalLucene solrrev documentlevelsecurity_rajanimaski_final
Lucene solrrev documentlevelsecurity_rajanimaski_final
 
LDAP Injection Techniques
LDAP Injection TechniquesLDAP Injection Techniques
LDAP Injection Techniques
 
Ieeepro techno solutions 2014 ieee java project - query services in cost ef...
Ieeepro techno solutions   2014 ieee java project - query services in cost ef...Ieeepro techno solutions   2014 ieee java project - query services in cost ef...
Ieeepro techno solutions 2014 ieee java project - query services in cost ef...
 
262 265
262 265262 265
262 265
 
IRJET- Secure Data Sharing Scheme for Mobile Cloud Computing using SEDASC
IRJET- Secure Data Sharing Scheme for Mobile Cloud Computing using SEDASCIRJET- Secure Data Sharing Scheme for Mobile Cloud Computing using SEDASC
IRJET- Secure Data Sharing Scheme for Mobile Cloud Computing using SEDASC
 
IRJET-Using Downtoken Secure Group Data Sharing on Cloud
IRJET-Using Downtoken Secure Group Data Sharing on CloudIRJET-Using Downtoken Secure Group Data Sharing on Cloud
IRJET-Using Downtoken Secure Group Data Sharing on Cloud
 

Similar to Web Services: Encapsulation, Reusability, and Simplicity

Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
LiquidHub
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
Daniel Egan
 

Similar to Web Services: Encapsulation, Reusability, and Simplicity (20)

Programming with Objective-C
Programming with Objective-CProgramming with Objective-C
Programming with Objective-C
 
Arc Ready Cloud Computing
Arc Ready Cloud ComputingArc Ready Cloud Computing
Arc Ready Cloud Computing
 
C# interview
C# interviewC# interview
C# interview
 
Dot Net Fundamentals
Dot Net FundamentalsDot Net Fundamentals
Dot Net Fundamentals
 
ArcReady - Architecting For The Cloud
ArcReady - Architecting For The CloudArcReady - Architecting For The Cloud
ArcReady - Architecting For The Cloud
 
Enterprise Library 2.0
Enterprise Library 2.0Enterprise Library 2.0
Enterprise Library 2.0
 
Dot net interview questions and asnwers
Dot net interview questions and asnwersDot net interview questions and asnwers
Dot net interview questions and asnwers
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Microsoft cloud 101
Microsoft cloud 101Microsoft cloud 101
Microsoft cloud 101
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 
Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)Building nTier Applications with Entity Framework Services (Part 1)
Building nTier Applications with Entity Framework Services (Part 1)
 
4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT4 pillars of OOPS CONCEPT
4 pillars of OOPS CONCEPT
 
CLARIN CMDI use case and flexible metadata schemes
CLARIN CMDI use case and flexible metadata schemes CLARIN CMDI use case and flexible metadata schemes
CLARIN CMDI use case and flexible metadata schemes
 
Linq To The Enterprise
Linq To The EnterpriseLinq To The Enterprise
Linq To The Enterprise
 
Answer ado.net pre-exam2018
Answer ado.net pre-exam2018Answer ado.net pre-exam2018
Answer ado.net pre-exam2018
 
Wikidata as a hub for the linked data cloud
Wikidata as a hub for the linked data cloudWikidata as a hub for the linked data cloud
Wikidata as a hub for the linked data cloud
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
 
Microsoft Entity Framework
Microsoft Entity FrameworkMicrosoft Entity Framework
Microsoft Entity Framework
 
Scaling Databricks to Run Data and ML Workloads on Millions of VMs
Scaling Databricks to Run Data and ML Workloads on Millions of VMsScaling Databricks to Run Data and ML Workloads on Millions of VMs
Scaling Databricks to Run Data and ML Workloads on Millions of VMs
 

More from hannonhill

Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Server
hannonhill
 
Using Cascade technology to increase SEO/Landing Page Optimization
Using Cascade technology to increase SEO/Landing Page OptimizationUsing Cascade technology to increase SEO/Landing Page Optimization
Using Cascade technology to increase SEO/Landing Page Optimization
hannonhill
 
Information Architecture and User Experience: The Journey, The Destination, T...
Information Architecture and User Experience: The Journey, The Destination, T...Information Architecture and User Experience: The Journey, The Destination, T...
Information Architecture and User Experience: The Journey, The Destination, T...
hannonhill
 
Connecting Ecommerce & Centralized Analytics to Cascade Server
Connecting Ecommerce & Centralized Analytics to Cascade ServerConnecting Ecommerce & Centralized Analytics to Cascade Server
Connecting Ecommerce & Centralized Analytics to Cascade Server
hannonhill
 
Data Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JSData Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JS
hannonhill
 
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
hannonhill
 
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
Accessibility in Practice:  Integrating Web Accessibility into Cascade TrainingAccessibility in Practice:  Integrating Web Accessibility into Cascade Training
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
hannonhill
 
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade ServerCrowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
hannonhill
 
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
hannonhill
 
Climbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground UpClimbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground Up
hannonhill
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Template
hannonhill
 
Cusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding PlatformCusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding Platform
hannonhill
 
Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!
hannonhill
 
Web Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web ServicesWeb Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web Services
hannonhill
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
hannonhill
 

More from hannonhill (20)

Cascade + Bootstrap = Awesome
Cascade + Bootstrap = AwesomeCascade + Bootstrap = Awesome
Cascade + Bootstrap = Awesome
 
Web Governance Crash Course: Creating a Sustainable Digital Transformation
Web Governance Crash Course: Creating a Sustainable Digital TransformationWeb Governance Crash Course: Creating a Sustainable Digital Transformation
Web Governance Crash Course: Creating a Sustainable Digital Transformation
 
Optimizing MySQL for Cascade Server
Optimizing MySQL for Cascade ServerOptimizing MySQL for Cascade Server
Optimizing MySQL for Cascade Server
 
Using Cascade technology to increase SEO/Landing Page Optimization
Using Cascade technology to increase SEO/Landing Page OptimizationUsing Cascade technology to increase SEO/Landing Page Optimization
Using Cascade technology to increase SEO/Landing Page Optimization
 
Information Architecture and User Experience: The Journey, The Destination, T...
Information Architecture and User Experience: The Journey, The Destination, T...Information Architecture and User Experience: The Journey, The Destination, T...
Information Architecture and User Experience: The Journey, The Destination, T...
 
2 Men 1 Site
2 Men 1 Site2 Men 1 Site
2 Men 1 Site
 
Connecting Ecommerce & Centralized Analytics to Cascade Server
Connecting Ecommerce & Centralized Analytics to Cascade ServerConnecting Ecommerce & Centralized Analytics to Cascade Server
Connecting Ecommerce & Centralized Analytics to Cascade Server
 
Data Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JSData Modeling with Cascade Server and HighCharts JS
Data Modeling with Cascade Server and HighCharts JS
 
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
Modernizing Internal Communications with Cascade Server, WordPress and MailCh...
 
Fun with Cascade Server!
Fun with Cascade Server!Fun with Cascade Server!
Fun with Cascade Server!
 
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
Accessibility in Practice:  Integrating Web Accessibility into Cascade TrainingAccessibility in Practice:  Integrating Web Accessibility into Cascade Training
Accessibility in Practice: Integrating Web Accessibility into Cascade Training
 
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade ServerCrowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
Crowdsourced Maps: From Google Forms to Fusion Tables to Cascade Server
 
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...	Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
Superautomatic! Data Feeds, Bricks, and Blocks, with Server-side Transformat...
 
Climbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground UpClimbing Migration Mountain: 200+ Sites from the Ground Up
Climbing Migration Mountain: 200+ Sites from the Ground Up
 
In Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified TemplateIn Pursuit of the Grand Unified Template
In Pursuit of the Grand Unified Template
 
Cusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding PlatformCusestarter or How We Built Our Own Crowdfunding Platform
Cusestarter or How We Built Our Own Crowdfunding Platform
 
Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!Cascade Server: Past, Present, and Future!
Cascade Server: Past, Present, and Future!
 
Web Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web ServicesWeb Forms, or How I Learned to Stop Worrying and Love Web Services
Web Forms, or How I Learned to Stop Worrying and Love Web Services
 
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...Outputting Their Full Potential: Using Outputs for Site Redesigns andDevelo...
Outputting Their Full Potential: Using Outputs for Site Redesigns and Develo...
 
Redesign in Cascade Server
Redesign in Cascade ServerRedesign in Cascade Server
Redesign in Cascade Server
 

Recently uploaded

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 

Web Services: Encapsulation, Reusability, and Simplicity

  • 1. Web Services: Encapsulation, Reusability, and Simplicity #CSUC14 Presented by Wing Ming Chan, September 16, 2014 Upstate Medical University chanw@upstate.edu 1
  • 2. Topics  Encapsulation: data and data manipulation hiding  Usernames and passwords  Creating phantom entities in Cascade  Fully qualified identifiers  Reusability: code ready to use without modification  AssetOperationHandlerService  Asset and Property classes  Simplicity: lines of code  Cascade and AssetTree classes  CascadeInstances and Report classes 2
  • 3. Part 0: Three Questions 3
  • 4. Purposes  Look for positive answers  Reveal the problems  Highlight the main issues 4
  • 5. Question 1  How many of you can write a web service program, doing something, anything, without hard-coding the username and password anywhere in your code?  Main concern  Security and encapsulation of sensitive data  Access restrictions 5
  • 6. Question 2  How many of you can work with the first node of the second multiple field in a data definition block, without looking at the read dump of the block? Can you hard-code the location of the node in you program?  Main concern  Encapsulation and reusability 6
  • 8. Question 3  Besides the use of require_once or include_once, how many of you can use a single semi-colon in your code to do the following:  Associate metadata set 1 with all folders in a site (including Base Folder)  Associate metadata set 2 with all files in the site  Associate metadata set 3 with all symlinks in the site  Requirements: no program-specific data allowed in the required/included files; all information related to metadata sets, folders, files, and symlinks must show up in your code  Main concerns  Reusability and simplicity 8
  • 10. The Typical Way of Starting a Program 10
  • 11. Problems?  Programs are tied with usernames, passwords, and WSDL URL’s  People can come and go  Changes of passwords  URL’s can change too (different instances)  Passwords exposed  Security  A single program used by multiple users  Usernames and passwords change depending on the users using the same program  Access restrictions 11
  • 12. Phantom: Episode I  Detachment of structuredData from dataDefinition in web services  Created by web services  Only affects data definition blocks (including those plugged into pages)  Can be created in pages, but haven’t figure out a way to reveal the hidden content 12
  • 19. The Other Side of the Same Coin I 19
  • 20. The Other Side of the Same Coin II 20
  • 21. Creating a Java Error 21
  • 22. A NIGHTMARE… 22  Pretend that I am you enemy  What I can do to you:  Detachment of data definitions from content types  Assigning an empty string to a checkbox in data definition blocks  Data definition manipulation with phantom nodes  How long will it take to solve the problem: Days? Weeks?
  • 23. Encapsulating Usernames and Passwords: a Two-Step Approach  Step 1: move usernames and passwords out of programs to authentication files  Step 2: hide usernames and passwords from the system altogether 23
  • 24. Moving Usernames and Passwords Out of Programs: Using Authentication Files 24
  • 29. Authentication File: Entry Point to Code Library 29
  • 30. The AssetOperationHandlerService Class: Encapsulating Operations  Encapsulation  Username and password  URL  The SoapClient object and all operations  All parameters required for operations  The instance $service:  Instantiated in the authentication files  Passed from client code to code library  Performs all basic operations in code library 30
  • 31. Fully Qualified Identifiers  When working with data definition blocks or pages, we need to work with nodes  A fully qualified identifier of a node is the full path of the node, including all the information about ancestors and absolute position  Example: pie;1;pie-is-sliced 31
  • 32. What Is Special About Fully Qualified Identifiers  Example: pie;1;pie-is-sliced  The ;1 part following an identifier indicates that the field is a multiple field  ;0 means that the node bearing this identifier is the first node in the set; ;1 means that the node is the second node of the set  Unlike array indexes, the fully qualified identifier of a node never changes, no matter how many cousins and siblings it has  A more complicated example: main-field; group;2;sub-group;1;text;3 32
  • 33. Why Fully Qualified Identifiers?  They never change: can be hard-coded in programs  Easy node look-up  Possible to use for and foreach loops  Encapsulation of arrays and stdClass objects 33
  • 36. Why OOP?  Encapsulation  Hiding complicated program logic  Hiding data and raw data structures  Reusability  The entire library consists of reusable code  Easy object retrieval  Providing look-up mechanism  Setting and editing data and metadata, and preventing unacceptable input  Error checking and exception handling  Inheritance  Problems with web services 36
  • 37. Problems with Web Services I  It is possible to delete the value of a required field using web services (e.g. in a metadata set)  Cascade won’t complain when an unacceptable boolean value is assigned to a field (e.g. fals instead of false)  An unacceptable boolean value is ignored  Unlike dateTime (which is represented by an object)  Cascade won’t complain when an unacceptable string value is assigned to a dropdown  An undefined item is introduced  An empty string will also work 37
  • 38. Problems with Web Services II  When a single-item checkbox is assigned an empty string, Cascade won’t complain  However, the associated data definition block cannot be viewed (a Java error)  The field should have been assigned the string ‘::CONTENT-XML-CHECKBOX::’ instead  Phantoms we have met 38
  • 39. Problems with Web Services III  Assignment of NULL vs. unset When modifying temporal settings for scheduled publishing (for a site, a publish set, or a destination), assignments of the NULL value to properties won’t work  Instead, we must unset the properties 39
  • 40. ASSET AND PROPERTY  Asset: an abstract class  Other abstract subclasses: ContainedAsset, Container, Block, Format, etc.  42 concrete classes corresponding to 42 asset types defined in the WSDL  All methods have returned values Method chaining possible  stdClass objects within an asset are represented by subclasses of Property 40
  • 41. Inheritance  Reusability  An asset class can be reused to deal with any assets of the same type Metadata-related classes can be reused in File, Page, Block (and its subclasses), Format (and its subclasses) and Symlink Members in a parent class inherited by child classes, avoiding repetition of code  Separate code files  Less code per file  Easier to maintain 41
  • 42. Exception Handling  All classes throw exceptions of various types  Client code is expected to deal with exceptions  Two modes of execution: strict and lenient  To throw or not to throw? Cascade::getAsset vs. Cascade::getX (e.g. Cascade::getPage) 42
  • 44. Writing Client Code  Client code does not look like ‘normal’ Cascade web service code  No username and password  No arrays of raw data or stdClass objects  Chained method calls  Handling of exceptions  A lot shorter: simplicity!  Normally, no use of new keyword  Easy retrieval of asset objects  Easy retrieval of associated objects of pages  High level classes: Cascade and AssetTree 44
  • 45. Retrieving an Asset Object 45
  • 46. Dumping an Asset Object 46
  • 47. Working With A Data Definition Block 47
  • 52. ASSETTREE  A tree structure consisting of:  Root container  Children  Sub-trees  What it is good for:  Creating reports  Modifying assets of a certain type or types  The AssetTree::traverse method  Visits the root, every children of the root, and recursively all sub-trees (depth-first traversal)  Accepts global functions, parameters, and results array (passed in by reference)  Global functions as filters 52
  • 57. Publishing Every Page in a Folder 57
  • 59. Phantom: Episode II  Detachment of structuredData from dataDefinition in web services  Created by changes of data definitions  Affects web services only 59
  • 60. CascadeInstances: The Ultimate Test for Simplicity 60
  • 62. Questions?  Tutorial: http://www.upstate.edu/cascade-admin/ projects/web-services/  Email: chanw@upstate.edu  A web service user group? 62