├── .gitignore ├── LICENSE ├── README.markdown ├── apex-mdapi ├── .project └── src │ ├── classes │ ├── MetadataDataController.cls │ ├── MetadataDataController.cls-meta.xml │ ├── MetadataDeployController.cls │ ├── MetadataDeployController.cls-meta.xml │ ├── MetadataRetrieveController.cls │ ├── MetadataRetrieveController.cls-meta.xml │ ├── MetadataService.cls │ ├── MetadataService.cls-meta.xml │ ├── MetadataServiceExamples.cls │ ├── MetadataServiceExamples.cls-meta.xml │ ├── MetadataServicePatcher.cls │ ├── MetadataServicePatcher.cls-meta.xml │ ├── MetadataServiceTest.cls │ ├── MetadataServiceTest.cls-meta.xml │ ├── RemoteSiteHelperController.cls │ ├── RemoteSiteHelperController.cls-meta.xml │ ├── RemoteSiteHelperTest.cls │ └── RemoteSiteHelperTest.cls-meta.xml │ ├── components │ ├── remotesitehelper.component │ ├── remotesitehelper.component-meta.xml │ ├── unzip.component │ ├── unzip.component-meta.xml │ ├── zip.component │ ├── zip.component-meta.xml │ ├── zipEntry.component │ └── zipEntry.component-meta.xml │ ├── documents │ ├── MetadataServicePatcher-meta.xml │ └── MetadataServicePatcher │ │ ├── MetadataServicePatchedCopy │ │ └── MetadataServicePatchedCopy-meta.xml │ ├── package.xml │ ├── pages │ ├── metadatabrowser.page │ ├── metadatabrowser.page-meta.xml │ ├── metadatadata.page │ ├── metadatadata.page-meta.xml │ ├── metadatadeploy.page │ ├── metadatadeploy.page-meta.xml │ ├── metadataretrieve.page │ ├── metadataretrieve.page-meta.xml │ ├── remotesitepage.page │ └── remotesitepage.page-meta.xml │ ├── staticresources │ ├── extjs.resource │ ├── extjs.resource-meta.xml │ ├── jszip.resource │ └── jszip.resource-meta.xml │ └── tabs │ ├── MetadataBrowser.tab │ ├── MetadataDeployDemo.tab │ └── MetadataRetrieveDemo.tab └── images ├── mdbrowsedemo.png ├── mddeploydemo.png ├── mdretrievedemo.png ├── remotesitehelper.png └── showcase-layouteditingviamdapi.png /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | apex-mdapi/.settings/com.salesforce.ide.core.prefs 3 | 4 | apex-mdapi/salesforce.schema 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c), FinancialForce.com, inc 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, 5 | are permitted provided that the following conditions are met: 6 | 7 | - Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | - Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | - Neither the name of the FinancialForce.com, inc nor the names of its contributors 13 | may be used to endorse or promote products derived from this software without 14 | specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 19 | THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 | OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 22 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /README.markdown: -------------------------------------------------------------------------------- 1 | Apex Wrapper Salesforce Metadata API 2 | ==================================== 3 | 4 | 5 | Deploy to Salesforce 7 | 8 | 9 | Documentation 10 | ------------- 11 | 12 | In addition to the documentation in this README, the following blogs also cover the library. 13 | 14 | - [Using Named Credentials with the Apex Wrapper Salesforce Metadata API (apex-mdapi)](https://www.gscloudsolutions.com/blogpost/Using-Named-Credentials-with-the-Apex-Wrapper-Salesforce-Metadata-API-apex-mdapi?blogpost=true&utm_source=twitter&utm_medium=social&utm_campaign=named_credentials) 15 | - [Automating the Creation of Flow Screens with Apex Metadata API](http://andyinthecloud.com/2015/11/28/automating-the-creation-of-flow-screens-with-apex-metadata-api/) 16 | - [Apex Metadata API Q&A](http://andyinthecloud.com/2014/11/22/apex-metadata-api-qa/) 17 | - [Apex Metadata API Streamlined and Simplified for Summer’14](http://andyinthecloud.com/2014/08/14/apex-metadata-api-streamlined-and-simplified-for-summer14/) 18 | - [Post Install Apex Metadata API Configuration Solved!](http://andyinthecloud.com/2014/07/29/post-install-apex-metadata-api-configuration-solved/) 19 | - [Apex Metadata API and Spring’14 : Keys to the Kingdom!](http://andyinthecloud.com/2014/04/24/apex-metadata-api-and-spring14-keys-to-the-kingdom/) 20 | - [Introduction to calling the Metadata API from Apex](http://andyinthecloud.com/2013/10/27/introduction-to-calling-the-metadata-api-from-apex/). 21 | - [Spring’14 Pre-Release : Updating Layouts in Apex](http://andyinthecloud.com/category/metadata-api/) 22 | - [“Look ma, no hands!” : Automating Install and Uninstall of Packages!](http://andyinthecloud.com/2013/06/23/look-ma-no-hands-automating-install-and-uninstall-of-packages/) 23 | - [Scripting the Apex Metadata API and Batch Apex Support](http://andyinthecloud.com/2013/05/06/scripting-the-apex-metadata-api-and-batch-apex-support/) 24 | - [Apex Metadata API Spring’13 Update : Org Settings Access](http://andyinthecloud.com/2013/03/10/apex-metadata-api-spring13-update-org-settings-access/) 25 | 26 | This API mirrors as much as possible the API types and operations described in the standard documentation. The behaviour and functionality provided is also as described in the Salesforce documentation, in terms of what metadata is available and accessable via the specific operations. 27 | 28 | - [Salesforce Metadata API Developers Guide](https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/) 29 | 30 | Showcase 31 | -------- 32 | 33 | This new section aims to showcase cool tools and applications people are building with this library. If you would like your name and creation in lights here pleaes raise a GitHub issue with the details and we will gladly showcase it! 34 | 35 | ![Demo Screenshot](https://raw.githubusercontent.com/financialforcedev/apex-mdapi/master/images/showcase-layouteditingviamdapi.png) 36 | **Layout Editing Tool** by [BoonPlus](https://github.com/BoonPlus) 37 | 38 | Background and Motivation 39 | ------------------------- 40 | 41 | There seems to be a growing number of Apex developers wanting to develop solutions or just handy utils that embrace the declarative nature of the platform. Including those in FinancialForce.com for that matter! Such solutions are dynamically adapting to custom fields or objects that need to be created by the administrator and/or customisations to objects in existing packages. 42 | 43 | As administrators leverage more and more of these solutions the topic of automation arises. Can the developers of these solutions help the administrator by implementing wizards or self configuring solutions without asking the administrator to create these manually and then have to reference them back into the solution? 44 | 45 | Strategies for calling from Apex 46 | -------------------------------- 47 | 48 | Salesforce provides a great number of API's for developers to consume, both off and on platform (as Apex developers). If you happen to be off platform (say in Heroku) and developing code to help automate administration. Then you can utilise the Salesforce Metadata API (via the Salesforce WebService Connector) to help with this. It is a robust and readily available API for creating objects, fields, pages and many other component types. 49 | 50 | While Salesforce offers on platform Apex developers a means to query some of this information (a subset of the Metadata API coverage) via Apex Describe, it does not as yet provide a means to manipulate this metadata from Apex natively. We are told this is in the pipeline, though I am personally not aware of when this will arrive. 51 | 52 | Before you read on, stop by and [up vote this idea](https://success.salesforce.com/ideaView?id=08730000000l4TkAAI) to have a native Metadata API! 53 | 54 | So what can we do in the meantime as Apex developers? Well it turns out that Apex is quite good at making outbound calls to Web Services and more recently REST based API's, all be it as always with a few governors to be aware. So why can Apex not call out to the Metadata Web Services API? After all, there is a WSDL for it and you have the ability as an Apex developer to import a WSDL into Apex and consume the code it generates to make the call... 55 | 56 | Examples 57 | -------- 58 | 59 | The following examples are a subset of those found in the [MetadataServiceExamples.cls](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls). 60 | 61 | ```java 62 | public static void createObject() 63 | { 64 | MetadataService.MetadataPort service = createService(); 65 | MetadataService.CustomObject customObject = new MetadataService.CustomObject(); 66 | customObject.fullName = 'Test__c'; 67 | customObject.label = 'Test'; 68 | customObject.pluralLabel = 'Tests'; 69 | customObject.nameField = new MetadataService.CustomField(); 70 | customObject.nameField.type_x = 'Text'; 71 | customObject.nameField.label = 'Test Record'; 72 | customObject.deploymentStatus = 'Deployed'; 73 | customObject.sharingModel = 'ReadWrite'; 74 | List results = 75 | service.createMetadata( 76 | new MetadataService.Metadata[] { customObject }); 77 | handleSaveResults(results[0]); 78 | } 79 | 80 | public static void createField() 81 | { 82 | MetadataService.MetadataPort service = createService(); 83 | MetadataService.CustomField customField = new MetadataService.CustomField(); 84 | customField.fullName = 'Test__c.TestField__c'; 85 | customField.label = 'Test Field'; 86 | customField.type_x = 'Text'; 87 | customField.length = 42; 88 | List results = 89 | service.createMetadata( 90 | new MetadataService.Metadata[] { customField }); 91 | handleSaveResults(results[0]); 92 | } 93 | 94 | public static void createPage() 95 | { 96 | MetadataService.MetadataPort service = createService(); 97 | MetadataService.ApexPage apexPage = new MetadataService.ApexPage(); 98 | apexPage.apiVersion = 25; 99 | apexPage.fullName = 'test'; 100 | apexPage.label = 'Test Page'; 101 | apexPage.content = EncodingUtil.base64Encode(Blob.valueOf('')); 102 | List results = 103 | service.createMetadata( 104 | new MetadataService.Metadata[] { apexPage }); 105 | handleSaveResults(results[0]); 106 | } 107 | 108 | public static void listMetadata() 109 | { 110 | MetadataService.MetadataPort service = createService(); 111 | List queries = new List(); 112 | MetadataService.ListMetadataQuery queryWorkflow = new MetadataService.ListMetadataQuery(); 113 | queryWorkflow.type_x = 'Workflow'; 114 | queries.add(queryWorkflow); 115 | MetadataService.ListMetadataQuery queryValidationRule = new MetadataService.ListMetadataQuery(); 116 | queryValidationRule.type_x = 'ValidationRule'; 117 | queries.add(queryValidationRule); 118 | MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, 25); 119 | for(MetadataService.FileProperties fileProperty : fileProperties) 120 | System.debug(fileProperty.fullName); 121 | } 122 | 123 | public static MetadataService.MetadataPort createService() 124 | { 125 | MetadataService.MetadataPort service = new MetadataService.MetadataPort(); 126 | service.SessionHeader = new MetadataService.SessionHeader_element(); 127 | service.SessionHeader.sessionId = UserInfo.getSessionId(); 128 | return service; 129 | } 130 | ``` 131 | 132 | You can view more examples [here](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls). 133 | 134 | Community Examples 135 | ------------------ 136 | 137 | - Thanks to [mohit-address](https://github.com/mohit-address) for submitting examples relating to updating picklist values. 138 | - Thanks to [KGFTW](https://github.com/KGFTW) for submitting an excellent example relating to [cloning reports](https://github.com/financialforcedev/apex-mdapi/issues/147). 139 | 140 | **Report Cloning with Apex Metadata API** 141 | 142 | ``` 143 | /** 144 | * Method cloneReport(String sFolderApiName, String sReportApiName, String tFolderApiName, String tReportApiName) 145 | * @param sFolderApiName: api name of the (source) folder of the report to clone 146 | * @param sReportApiName: api name of the (source) report to clone 147 | * @param tFolderApiName: api name of the (target) folder to create the cloned report in 148 | * @param tReportApiName: api name of the (target) cloned report 149 | */ 150 | public static void cloneReport(String sFolderApiName, String sReportApiName, String tFolderApiName, String tReportApiName) { 151 | MetadataService.MetadataPort service = new MetadataService.MetadataPort(); 152 | service.SessionHeader = new MetadataService.SessionHeader_element(); 153 | service.SessionHeader.sessionId = UserInfo.getSessionId(); 154 | 155 | // Get the report to clone 156 | MetadataService.Report reportToClone = (MetadataService.Report) service.readMetadata('Report', new String[] { sFolderApiName+'/'+sReportApiName }).getRecords()[0]; 157 | 158 | // Instanciate a new one to attribute the same metadata from the report to clone 159 | MetadataService.Report apexReport = new MetadataService.Report(); 160 | // Set the cloned report properties from parameters and the source report 161 | apexReport.name = reportToClone.name + ' Clone'; 162 | apexReport.fullName = tFolderApiName + '/' + tReportApiName; 163 | apexReport.reportType = reportToClone.reportType; 164 | apexReport.description = reportToClone.description; 165 | apexReport.format = reportToClone.format; 166 | apexReport.filter = reportToClone.filter; 167 | apexReport.showDetails = reportToClone.showDetails; 168 | apexReport.sortColumn = reportToClone.sortColumn; 169 | apexReport.sortOrder = reportToClone.sortOrder; 170 | apexReport.groupingsAcross = reportToClone.groupingsAcross; 171 | apexReport.groupingsDown = reportToClone.groupingsDown; 172 | apexReport.chart = reportToClone.chart; 173 | apexReport.timeFrameFilter = reportToClone.timeFrameFilter; 174 | apexReport.columns = reportToClone.columns; 175 | 176 | // Create the report clone 177 | List results = service.createMetadata(new MetadataService.Metadata[] { apexReport }); 178 | 179 | // Handle results 180 | handleSaveResults(results[0]); 181 | } 182 | ``` 183 | 184 | You can use the [report clone example](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceExamples.cls#L1542) like this... 185 | 186 | ``` 187 | MetadataServiceExamples.cloneReport('Source_Folder_Api_Name','Source_Report_Api_Name','Target_Folder_Api_Name','Target_Report_Api_Name'); 188 | ``` 189 | 190 | Metadata Retrieve Demo 191 | ---------------------- 192 | 193 | The [MetadataRetrieveController](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataRetrieveController.cls) and [metadataretrieve.page](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/pages/metadataretrieve.page) samples demonstrate using the excellent [JSZip](http://stuartk.com/jszip/) library to handle the zip retrieve file contents, passing the zip entries back to the controller for handling in Apex. This sample stores the file data in a list in the controller, though you could send or process the file anyway you see fit. It also shows how to handle the AsyncRequest and checkStatus calls. Enjoy and here is a screenshot! 194 | 195 | ![Metadata Retrieve Demo Screenshot](https://raw.github.com/financialforcedev/apex-mdapi/master/images/mdretrievedemo.png) 196 | 197 | **NOTE:** I nearly got this working without using [JSZip](http://stuartk.com/jszip/), in a pure 100% native Apex and Visualforce way. I utilised the Metadata CRUD API to dynamically upload the zip file as a Static Resource. Then used PageReference.getContent to peak into it! However there seems to be a bug with Static Resources containing files with spaces in their names! No matter how I escaped the URL, I got a 404. I'm researching this further. So watch this space... 198 | 199 | Metadata Deploy Demo 200 | --------------------- 201 | 202 | **IMPORTANT NOTE:** This demo allows you (in theory since I've not tested all) to deploy any Metadata Component types, including ApexClass. In many use cases it is possible to deploy Apex using the existing tools Salesforce provides: changesets, migration toolkit (aka Ant ) and packages. Only utilise this capability if you're sure your use case requires it. Note that this does not bypass the need to deploy test code with the correct coverage when deploying into production environments. 203 | 204 | The ability to deploy Apex code (and other Metadata component types not covered by the CRUD operations) is something it seems a lot of people have been asking about. Using the JSZip library I have got this working. I also decided to create some Visualforce components to wrap this library to make it a little easier to use. These components are called zip, zipEntry and unzip, you can see them in action on the pages used by this demo and the one above. 205 | 206 | To illustrate error handling, I've shown in the screen shot a deliberate failed deploy, since getting the feedback is just as an important aspect of the solution as a successful one! The key implementation parts of the sample are shown below, enjoy! 207 | 208 | ![Metadata Deploy Demo Screenshot](https://raw.github.com/financialforcedev/apex-mdapi/master/images/mddeploydemo.png) 209 | 210 | ```java 211 | public String getPackageXml() 212 | { 213 | return '' + 214 | '' + 215 | '' + 216 | 'HelloWorld' + 217 | 'ApexClass' + 218 | '' + 219 | '26.0' + 220 | ''; 221 | } 222 | 223 | public String getHelloWorldMetadata() 224 | { 225 | return '' + 226 | '' + 227 | '26.0' + 228 | 'Active' + 229 | ''; 230 | } 231 | 232 | public String getHelloWorld() 233 | { 234 | return 'public class HelloWorld' + 235 | '{' + 236 | 'public static void helloWorld()' + 237 | '{' + 238 | 'System.debug(\' Hello World\');' + 239 | '}' + 240 | '}'; 241 | } 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | public PageReference deployZip() 256 | { 257 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Deploying...')); 258 | 259 | // Deploy zip file posted back from the page action function 260 | MetadataService.MetadataPort service = createService(); 261 | MetadataService.DeployOptions deployOptions = new MetadataService.DeployOptions(); 262 | deployOptions.allowMissingFiles = false; 263 | deployOptions.autoUpdatePackage = false; 264 | deployOptions.checkOnly = false; 265 | deployOptions.ignoreWarnings = false; 266 | deployOptions.performRetrieve = false; 267 | deployOptions.purgeOnDelete = false; 268 | deployOptions.rollbackOnError = true; 269 | deployOptions.runAllTests = false; 270 | deployOptions.runTests = null; 271 | deployOptions.singlePackage = true; 272 | AsyncResult = service.deploy(ZipData, DeployOptions); 273 | return null; 274 | } 275 | 276 | ``` 277 | 278 | **NOTE:** I am using Visualforce state (aka Viewstate) and Visualforce AJAX in the above two examples. This will limit the size of the files and zip file being exchanged. Use of JavaScript Remoting will give you increased flexibility in file size (docs state a response size of 15MB is supported). However this will mean storing state in a Custom Object, the slight additional complexity of this I wanted to avoid in these samples. As noted below I have recently (December 2012) enhanced the zip components in another repo, they are based on those in this repo, so are fairly simple to retro fit, take a look at the samples there first. Finally, keep in mind that you can also for most other Metadata Component types use the CRUD operations as shown above, which avoid any zip file handling. 279 | 280 | You can review the [MetadataDeployController](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataDeployController.cls) and [metadatadeploy.page](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/pages/metadatadeploy.page) for the full code. I have also included some zip VF components. Starting from December 2012, I created a dedicated repo for zip handling [here](https://github.com/financialforcedev/apex-zip) so if you're interested in these, please refer to this repo for the latest. 281 | 282 | Metadata Explore Demo 283 | --------------------- 284 | 285 | With my recent Sencha skills, I decided to see if I could start the roots of a Metadata Explorer tool, using the **describeMetadata** API call. I've commited the basics of it into the repo, here is a screenshot to give you an idea. It works by using Sencha Stores and the Tree control to incrementally load the tree as the user expands the Metadata Types, quite fun! 286 | 287 | ![Metadata Browse Demo Screenshot](https://raw.github.com/financialforcedev/apex-mdapi/master/images/mdbrowsedemo.png) 288 | 289 | You can study the Visualforce page [here](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/pages/metadatabrowser.page) which mostly contains the Sencha code, making use of the [metadatadata](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/pages/metadatadata.page) page as a data proxy for the Sencha store. The controller for this data proxy page is [here](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataDataController.cls). Which emits the JSON data (using calls to the describeMetadata API call) used by the Sencha store . 290 | 291 | Known Issues and Resolutions 292 | ---------------------------- 293 | 294 | - If you recieve the error message *'Insufficient access; cannot execute Metadata operation with PAC enabled session id'* within Apex code within a managed package utilising this library. Please ensure to changed the API access from Restricted to Unrestricted on your Package definition. 295 | - If you receive the error messag *'System.CalloutException: IO Exception: Read timed out'* then take a look at this excellent resolution to the problem [here](https://github.com/financialforcedev/apex-mdapi/issues/77). 296 | 297 | How to call the Salesforce Metadata API from Apex 298 | ------------------------------------------------- 299 | 300 | Salesforce have been promoting recently the Metadata REST API. While this is still not a native API to Apex, it would be a lot easier to call than the Web Service one, though you would have develop your own wrapper classes. Unfortunatly this API is still in pilot and I have been told by Salesforce its appearance as a GA API is still someway out, sadly. 301 | 302 | One option is to download the Metadata WSDL from the Tools page under the Develop menu and attempt to generate Apex code from this, using the Generate from WSDL button. This does not work straight away, some changes to the WSDL and updates to the generated code is required. Fortunately this library has done all this for you, so all you need to do is take the MetadataService.cls and MetadataServiceTest.cls and get started with the examples included. 303 | 304 | - [MetadataService.cls](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls) 305 | - [MetadataServiceTest.cls](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServiceTest.cls) 306 | - The following so called CRUD operations are useable within Apex, **createMetadata**, **readMetadata**, **updateMetadata**, **upsertMetadata**, **renameMetadata** and **deleteMetadata**. 307 | - As well as **listMetadata** and **describeMetadata**. 308 | - With a bit of help from a Javascript library, the infamous **retrieve** and **deploy** also become workable. 309 | 310 | **Note:** The CRUD operations do not support Apex Class or Apex Trigger components sadly, this is a API restriction and not an issue with calling from Apex as such. 311 | 312 | I've created this Github repo to capture a modified version of the generated Apex class around the Metadata API, which addresses the problems above so that you can download it and get started straight away. 313 | 314 | Remote Site Settings are a must; the tool can help! 315 | --------------------------------------------------- 316 | A recent contribution has taken much of the work that was done in the [DLRS Tool](https://github.com/afawcett/declarative-lookup-rollup-summaries) for automating the creation of a remote site setting and turned it into a visualforce component that is easily extensible for anyone needing a remote site setting created. See the [remotesitepage.page](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/pages/remotesitepage.page) as well as the [remotesitehelper.component](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/components/remotesitehelper.component) for full code. In short, this page will automatically detect if the salesforce instance you're using can access the metadata api; and if it cannot access, it gives you the ability to specify the remote site setting you want, and automatically populate the correct url. It also allows you to have a simple "welcome style" page that has some fanciness. Here are the component parameters: 317 | - rssName="mdapi" 318 | - rssDescription="SFDC to SFDC metadata api." 319 | - pageOverview="This is an awesome overview of my tool." 320 | - pageOverviewLinkURL="http://google.com" 321 | - pageOverviewLinkText="Google This tool!" 322 | - pageSectionTitle="My Awesome Package Welcome Page" 323 | - pageSectionSubTitle="Welcome" 324 | - pageImageURL="http://someurltoanimage.com/image.png" 325 | 326 | Here is what the page will look like with the above configuration. 327 | ![Demo Screenshot](https://raw.githubusercontent.com/financialforcedev/apex-mdapi/master/images/remotesitehelper.png) 328 | 329 | How to create your own MetadataService.cls 330 | ------------------------------------------ 331 | 332 | **IMPORTANT NOTE:** This library contains a pre-build version of the Metadata API, you only need to follow these steps if the version of the Metadata API you want is not reflected in the repository currently or if you have modified the patcher script to customise it for your own needs. 333 | 334 | - Generating a valid Apex MetadataService class 335 | - Download and edit the WSDL 336 | - Change the Port name from 'Metadata' to 'MetadataPort' 337 | - Add displayLocationInDecimal to the CustomField definition. 338 | 339 | - Add gracePeriodDays to the HistoryRetentionPolicy definition. 340 | 341 | - Locate the CustomMetadataValue complextype, change the type of the 'value' element to 'xsd:string' 342 | - Locate the FieldValue complextype, change the type of the 'value' element to 'xsd:string' 343 | - Generate Apex from this WSDL 344 | - When prompted give it a name of MetadataServiceImported 345 | - Verify a MetadataServiceImported class has been created 346 | - Run the Patch script to generate a new MetadataService class (as a Document) 347 | - Check the Release Notes for API changes, locate the Metadata API section and update MetadataServicePatcher.METADATA_TYPES 348 | - Update MetadataServicePatcher.API_VERSION 349 | - Ensure you have a Document Folder called MetadataServicePatcher (Developer Name) 350 | - Run the following code from execute annoynmous in Developer Console 351 | MetadataServicePatcher.patch(); 352 | - Verify this has created a MetadataServicePatched Document in the abov folder 353 | - Update MetadataService.cls 354 | - Open the MetadataServicePatched Document and copy the code 355 | - Paste the code over the current or new MetadataService.cls class 356 | (recommend MavensMate for this as the file is some 8000+ lines long) 357 | - Check for any left over references to MetadataServiceImported in MetadataService and change them to MetadataService 358 | - Update MetadataServiceTest.cls 359 | - See this for guidelines http://andyinthecloud.com/2013/05/11/code-coverage-for-wsdl2apex-generated-classes 360 | - Future releases of the patch script may also generate this class 361 | - Update all the Metadata files to the latest API 362 | 363 | **NOTE:** You can review the changes made to the standard Saleforce generated Web Service Apex class for the Metadata API, by reading the comments at the top of the [MetadataServicePatcher.cls](https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataServicePatcher.cls) class. 364 | 365 | Release History 366 | --------------- 367 | 368 | **Update: 25th June 2016:** 369 | - Updated to Summer'16 v37.0 Metadata API 370 | 371 | **Update: 17th April 2016:** 372 | - Updated to Spring'16 v36.0 Metadata API 373 | 374 | **Update: 2nd Nov 2015:** 375 | - Updated to Winter'16 v35.0 Metadata API 376 | 377 | **Update: 4th May 2015:** 378 | - Created new Remote Site Helper Page. 379 | 380 | **Update: 7th April 2015:** 381 | - Updated to **Spring'15 Metadata API (v33.0)** 382 | 383 | **Update: 20th November 2014:** 384 | - Updated to **Winter'15 Metadata API (v32.0)** 385 | - Minor changes, some new component types, blog to follow. 386 | 387 | **Update: 14th August 2014:** 388 | - Updated to **Summer'14 Metadata API (v31.0)**, signifcant changes to the API, see [blog](http://andyinthecloud.com/2014/08/14/apex-metadata-api-streamlined-and-simplified-for-summer14/). 389 | 390 | **Update: 24th April 2014:** 391 | - Updated to **Spring'14 Metadata API (v30.0)**, significant new features, see [blog](http://andyinthecloud.com/2014/04/24/apex-metadata-api-and-spring14-keys-to-the-kingdom/). 392 | 393 | **Update: 27th October 2013:** 394 | - A new introduction to the API has been published [here](http://andyinthecloud.com/2013/10/27/introduction-to-calling-the-metadata-api-from-apex/) 395 | - A new supporting Visualforce example has also been created to show how to use apex:actionPoller 396 | 397 | **Update: 30th August 2013:** 398 | - Very interesting fix for the 'delete' CRUD operation (for fields), see this StackExchange [answer](http://salesforce.stackexchange.com/questions/15902/how-to-dynamically-set-type-x-value-for-metadata-customfield/15913#15913) for more and the MetadataServiceExamples.deleteField method 399 | 400 | **Update: 20th June 2013:** 401 | - Updated to **Summer'13 Metadata API (v28.0)**, more cool stuff to follow on this, such an Apex package installer UI! 402 | 403 | **Update: 6th May 2013:** 404 | - Updated MetadataCreateJob.cls, new feature to process Metadata API requests in Batch Apex, see examples. 405 | 406 | **Update: 5th May 2013:** 407 | - Updated MetadataServiceTest.cls, now provides 100% code coverage of MetadataService.cls! 408 | 409 | **Update: 10th March 2013:** 410 | - Updated to **Spring'13 Metadata API (v27.0)**, more info on new features of this version [here](http://developer.force.com/releases/release/Spring13/Bulk+Metadata+and+Streaming+API+Updates). Also added new samples for Settings configuraiton, see blog [here](http://andyinthecloud.com/2013/03/10/apex-metadata-api-spring13-update-org-settings-access). 411 | 412 | **Update: 3rd March 2013:** 413 | - Updated MetadataServiceExample.cls with more sample code creating various field types. 414 | 415 | **Update: 11th November 2012:** 416 | - Updated the Retrieve Demo to utilise 'describeMetadata' API call to allow the user to select which Metadata Type to list and retrieve. 417 | - Added 'Metadata Explore' demo (see below) a Sencha powered demo of 'describeMetadata' and 'listMetadata' API's 418 | 419 | 420 | About the Author 421 | ---------------- 422 | 423 | My name is Andrew Fawcett, I am the CTO of FinancialForce.com, if you want to ask questions you can do so via the Issues tab or just follow me on Twitter, my name is [andyinthecloud](http://twitter.com/andyinthecloud) 424 | 425 | I enjoy making life easier and enabling more people to help me in this endeavour! And thus API's are one of my main passions. Hence this article! Enjoy and do let me know what cool time saving solutions you create! 426 | -------------------------------------------------------------------------------- /apex-mdapi/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | apex.md 4 | 5 | 6 | 7 | 8 | 9 | com.salesforce.ide.builder.default 10 | 11 | 12 | 13 | 14 | com.salesforce.ide.builder.online 15 | 16 | 17 | 18 | 19 | 20 | com.salesforce.ide.nature.default 21 | com.salesforce.ide.nature.online 22 | 23 | 24 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataDataController.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012, FinancialForce.com, inc 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * - Neither the name of the FinancialForce.com, inc nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | **/ 26 | 27 | public with sharing class MetadataDataController 28 | { 29 | private static final Integer METADATA_API_VERSION = 30 | Integer.valueOf(new MetadataService.MetadataPort().endpoint_x.substringAfterLast('/')); 31 | 32 | public String Data {get; set;} 33 | 34 | public PageReference constructResponse() 35 | { 36 | try { 37 | List nodes = new List(); 38 | String node = ApexPages.currentPage().getParameters().get('node'); 39 | if(node=='root') 40 | { 41 | // List available Metadata Types via the 'describeMetadata' API call 42 | MetadataService.MetadataPort service = MetadataServiceExamples.createService(); 43 | MetadataService.DescribeMetadataResult describeResult = service.describeMetadata(METADATA_API_VERSION); 44 | for(MetadataService.DescribeMetadataObject metadataObject : describeResult.metadataObjects) 45 | { 46 | nodes.add(new FolderNode(metadataObject.xmlName, metadataObject.xmlName, false, null)); 47 | // Include child Metadata Types (such as CustomField, ValidationRule etc..) 48 | if(metadataObject.childXmlNames!=null) 49 | for(String childXmlName : metadataObject.childXmlNames) 50 | if(childXmlName!=null) 51 | nodes.add(new FolderNode(childXmlName, childXmlName, false, null)); 52 | } 53 | } 54 | else 55 | { 56 | // List Metadata for the given type via the listMetadata API call 57 | MetadataService.MetadataPort service = MetadataServiceExamples.createService(); 58 | List queries = new List(); 59 | MetadataService.ListMetadataQuery query = new MetadataService.ListMetadataQuery(); 60 | query.type_x = node; 61 | queries.add(query); 62 | MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, METADATA_API_VERSION); 63 | 64 | // Emit leaf nodes (ensure unique IDs) 65 | if(fileProperties!=null) { 66 | Integer index = 0; 67 | for(MetadataService.FileProperties fileProperty : fileProperties) 68 | nodes.add(new LeafNode(fileProperty.fullName + ':' + index++, EncodingUtil.urlDecode(fileProperty.fullName, 'UTF-8'), false)); 69 | } 70 | } 71 | Data = JSON.serialize(nodes); 72 | } 73 | catch (Exception e) { 74 | Data = JSON.serialize(new List { new FolderNode('error', e.getMessage(), false, null) }); 75 | } 76 | return null; 77 | } 78 | 79 | public abstract class Node 80 | { 81 | public String id; 82 | public String text; 83 | public String cls; 84 | public boolean leaf; 85 | public boolean checked; 86 | public boolean expanded; 87 | public List children; 88 | } 89 | 90 | public class FolderNode extends Node 91 | { 92 | public FolderNode(String id, String text, boolean expanded, List children) 93 | { 94 | this.id = id; 95 | this.text = text; 96 | this.cls = 'folder'; 97 | this.leaf = false; 98 | this.checked = false; 99 | this.expanded = expanded; 100 | this.children = children; 101 | } 102 | } 103 | 104 | public class LeafNode extends Node 105 | { 106 | public LeafNode(String id, String text, boolean checked) 107 | { 108 | this.id = id; 109 | this.text = text; 110 | this.cls = null; 111 | this.leaf = true; 112 | this.checked = checked; 113 | this.expanded = false; 114 | this.children = null; 115 | } 116 | } 117 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataDataController.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataDeployController.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012, FinancialForce.com, inc 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * - Neither the name of the FinancialForce.com, inc nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | **/ 26 | 27 | public with sharing class MetadataDeployController 28 | { 29 | public String ZipData { get; set; } 30 | 31 | public MetadataService.AsyncResult AsyncResult {get; private set;} 32 | 33 | public String getPackageXml() 34 | { 35 | return '' + 36 | '' + 37 | '' + 38 | 'HelloWorld' + 39 | 'ApexClass' + 40 | '' + 41 | '26.0' + 42 | ''; 43 | } 44 | 45 | public String getHelloWorldMetadata() 46 | { 47 | return '' + 48 | '' + 49 | '28.0' + 50 | 'Active' + 51 | ''; 52 | } 53 | 54 | public String getHelloWorld() 55 | { 56 | return 'public class HelloWorld' + 57 | '{' + 58 | 'public static void helloWorld()' + 59 | '{' + 60 | 'System.debug(\' Hello World\');' + 61 | '}' + 62 | '}'; 63 | } 64 | 65 | public PageReference deployZip() 66 | { 67 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Deploying...')); 68 | 69 | // Deploy zip file posted back from the page action function 70 | MetadataService.MetadataPort service = createService(); 71 | MetadataService.DeployOptions deployOptions = new MetadataService.DeployOptions(); 72 | deployOptions.allowMissingFiles = false; 73 | deployOptions.autoUpdatePackage = false; 74 | deployOptions.checkOnly = false; 75 | deployOptions.ignoreWarnings = false; 76 | deployOptions.performRetrieve = false; 77 | deployOptions.purgeOnDelete = false; 78 | deployOptions.rollbackOnError = true; 79 | deployOptions.testLevel = 'NoTestRun'; 80 | deployOptions.singlePackage = true; 81 | AsyncResult = service.deploy(ZipData, DeployOptions); 82 | return null; 83 | } 84 | 85 | public PageReference checkAsyncRequest() 86 | { 87 | // Check the status of the retrieve request 88 | MetadataService.MetadataPort service = createService(); 89 | MetadataService.DeployResult deployResult = service.checkDeployStatus(AsyncResult.Id, true); 90 | if(deployResult.done) 91 | { 92 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Deployment complete')); 93 | 94 | // Deployment errors? 95 | if(deployResult.details!=null && deployResult.details.componentFailures!=null) 96 | for(MetadataService.DeployMessage deployMessage : deployResult.details.componentFailures) 97 | if(deployMessage.problem!=null) 98 | ApexPages.addMessage( 99 | new ApexPages.Message(ApexPages.Severity.Error, 100 | deployMessage.fileName + 101 | ' (Line: ' + deployMessage.lineNumber + ': Column:' + deployMessage.columnNumber + ') : ' + 102 | deployMessage.problem)); 103 | AsyncResult = null; 104 | } 105 | else 106 | { 107 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Deploying...')); 108 | } 109 | return null; 110 | } 111 | 112 | private static MetadataService.MetadataPort createService() 113 | { 114 | MetadataService.MetadataPort service = new MetadataService.MetadataPort(); 115 | service.SessionHeader = new MetadataService.SessionHeader_element(); 116 | service.SessionHeader.sessionId = UserInfo.getSessionId(); 117 | return service; 118 | } 119 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataDeployController.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataRetrieveController.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012, FinancialForce.com, inc 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * - Neither the name of the FinancialForce.com, inc nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | **/ 26 | 27 | /** 28 | * This example demonstrates how to utilise the Metadata API Retrieve operation inconjunction with the JSZip JavaScript library 29 | **/ 30 | public with sharing class MetadataRetrieveController 31 | { 32 | private static final Integer METADATA_API_VERSION = 33 | Integer.valueOf(new MetadataService.MetadataPort().endpoint_x.substringAfterLast('/')); 34 | 35 | public List MetaDataTypes {get; set;} 36 | public String MetaDataType {get; set;} 37 | public List MetaDataItems {get; set;} 38 | public String MetaDataFolder {get; set;} 39 | public String MetaDataItem {get; set;} 40 | public String MetadataFileName {get; set;} 41 | public String MetadataFileData {get; set;} 42 | public MetadataService.AsyncResult AsyncResult {get; private set;} 43 | public String MetaDataRetrieveZip { get; private set; } 44 | public List MetadataFiles { get; set; } 45 | 46 | public PageReference init() 47 | { 48 | // List available Metadata Types via the 'describeMetadata' API call 49 | MetadataService.MetadataPort service = createService(); 50 | MetadataService.DescribeMetadataResult describeResult = service.describeMetadata(METADATA_API_VERSION); 51 | List metadataTypeNames = new List(); 52 | for(MetadataService.DescribeMetadataObject metadataObject : describeResult.metadataObjects) 53 | { 54 | metadataTypeNames.add(metadataObject.xmlName); 55 | // Include child Metadata Types (such as CustomField, ValidationRule etc..) 56 | if(metadataObject.childXmlNames!=null) 57 | for(String childXmlName : metadataObject.childXmlNames) 58 | if(childXmlName!=null) 59 | metadataTypeNames.add(childXmlName); 60 | } 61 | 62 | // Sort Metadata Types 63 | metadataTypeNames.sort(); 64 | MetaDataTypes = new List(); 65 | for(String metadataTypeName : metadataTypeNames) 66 | MetaDataTypes.add(new SelectOption(metadataTypeName, metadataTypeName)); 67 | 68 | // Default to first Metadata Type returned 69 | MetaDataType = MetaDataTypes[0].getValue(); 70 | // Retrieve Metadata items for the selected Metadata Type 71 | listMetadataItems(); 72 | return null; 73 | } 74 | 75 | public PageReference listMetadataItems() 76 | { 77 | // List Metadata items for the selected Metadata Type 78 | MetaDataItems = new List(); 79 | MetadataService.MetadataPort service = createService(); 80 | List queries = new List(); 81 | MetadataService.ListMetadataQuery queryLayout = new MetadataService.ListMetadataQuery(); 82 | if(MetaDataFolder!=null && MetaDataFolder.length()>0) 83 | queryLayout.folder = MetaDataFolder; 84 | queryLayout.type_x = MetaDataType; 85 | queries.add(queryLayout); 86 | MetadataService.FileProperties[] fileProperties = service.listMetadata(queries, METADATA_API_VERSION); 87 | 88 | // Sort 89 | List fullNames = new List(); 90 | if(fileProperties!=null) 91 | { 92 | for(MetadataService.FileProperties fileProperty : fileProperties) 93 | fullNames.add(fileProperty.fullName); 94 | fullNames.sort(); 95 | for(String fullName : fullNames) 96 | MetaDataItems.add(new SelectOption(fullName,EncodingUtil.urlDecode(fullName, 'UTF-8'))); 97 | } 98 | 99 | return null; 100 | } 101 | 102 | public PageReference retrieveMetadataItem() 103 | { 104 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Retrieving metadata...')); 105 | 106 | // Reset state from any previous requests 107 | MetaDataRetrieveZip = null; 108 | MetadataFiles = null; 109 | 110 | // Construct unmanaged package with list of desired components to retrieve in zip 111 | MetadataService.MetadataPort service = createService(); 112 | MetadataService.RetrieveRequest retrieveRequest = new MetadataService.RetrieveRequest(); 113 | retrieveRequest.apiVersion = METADATA_API_VERSION; 114 | retrieveRequest.packageNames = null; 115 | retrieveRequest.singlePackage = true; 116 | retrieveRequest.specificFiles = null; 117 | retrieveRequest.unpackaged = new MetadataService.Package_x(); 118 | retrieveRequest.unpackaged.types = new List(); 119 | MetadataService.PackageTypeMembers packageType = new MetadataService.PackageTypeMembers(); 120 | packageType.name = MetaDataType; 121 | packageType.members = new String[] { MetadataFolder, MetaDataItem }; 122 | retrieveRequest.unpackaged.types.add(packageType); 123 | AsyncResult = service.retrieve(retrieveRequest); 124 | 125 | return null; 126 | } 127 | 128 | public PageReference checkAsyncRequest() 129 | { 130 | // Check the status of the retrieve request 131 | MetadataService.MetadataPort service = createService(); 132 | MetadataService.RetrieveResult retrieveResult = service.checkRetrieveStatus(AsyncResult.Id, true); 133 | if(retrieveResult.done) 134 | { 135 | // Errors? 136 | if(retrieveResult.status != 'Succeeded') 137 | { 138 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, retrieveResult.errorMessage)); 139 | AsyncResult = null; 140 | } 141 | else 142 | { 143 | // Place Base64 encoded zip data onto the page for the JSZip library to handle 144 | MetaDataRetrieveZip = retrieveResult.zipFile; 145 | MetadataFiles = new List(); 146 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Expanding...')); 147 | AsyncResult = null; 148 | } 149 | } 150 | else 151 | { 152 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Retrieving metadata...')); 153 | } 154 | 155 | return null; 156 | } 157 | 158 | public PageReference receiveMetadataZipFile() 159 | { 160 | // In this example the retrieved metadata is stored in viewstate in production cases you would probably use a custom object / attachment 161 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Expanding ' + MetaDataFileName + '...')); 162 | MetadataFile metaDataFile = new MetadataFile(); 163 | metaDataFile.fullName = MetaDataFileName; 164 | metaDataFile.content = MetaDataFileData; 165 | MetadataFiles.add(metaDataFile); 166 | return null; 167 | } 168 | 169 | public PageReference receiveComplete() 170 | { 171 | // Completed, cleared Base64 encoded zip data from viewstate 172 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, 'Metadata retrieve completed')); 173 | MetaDataRetrieveZip = null; 174 | return null; 175 | } 176 | 177 | private static MetadataService.MetadataPort createService() 178 | { 179 | MetadataService.MetadataPort service = new MetadataService.MetadataPort(); 180 | service.SessionHeader = new MetadataService.SessionHeader_element(); 181 | service.SessionHeader.sessionId = UserInfo.getSessionId(); 182 | return service; 183 | } 184 | 185 | /** 186 | * Simple container class for retrieve metadata file, may as well leverage the Metadata API class for this 187 | **/ 188 | public class MetadataFile extends MetadataService.MetadataWithContent 189 | { 190 | public String getFullname() 191 | { 192 | return fullName; 193 | } 194 | 195 | public String getContent() 196 | { 197 | return content; 198 | } 199 | } 200 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataRetrieveController.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataService.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataServiceExamples.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataServicePatcher.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, FinancialForce.com, inc 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * - Neither the name of the FinancialForce.com, inc nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | **/ 26 | 27 | /** 28 | This patch script performs the following changes to the default WSDL2Apex tool output 29 | 30 | - Modify the end point to be dynamic 31 | - public String endpoint_x = URL.getOrgDomain().toExternalForm() + '/services/Soap/m/28.0'; 32 | - Make 'Metadata' inner class 'virtual' 33 | - Make 'MetadataWithContent' inner class 'virtual' 34 | - Review WSDL for types that extend 'tns:Metadata' and update related Apex classes to also extend Metadata 35 | - Review WSDL for types that extend 'tns:MetadataWithContent' and update related Apex classes to also extend MetadataWithContent 36 | - Apply the following to each class that extends Metadata, e.g. for CustomObject 37 | Add the following at the top of the class 38 | public String type = 'CustomObject'; 39 | public String fullName; 40 | Add the following at the top of the private static members 41 | private String[] type_att_info = new String[]{'xsi:type'}; 42 | private String[] fullName_type_info = new String[]{'fullName','http://www.w3.org/2001/XMLSchema','string','0','1','false'}; 43 | Add 'fullName' as the first item in the field_order_type_info String array, e.g. 44 | private String[] field_order_type_info = new String[]{'fullName', 'actionOverrides' …. 'webLinks'}; 45 | - Apply the following to each class that extends MetadataWithContent, e.g. for ApexPage 46 | Add the following after 'fullName' 47 | public String content; 48 | Add the following after 'fullName_type_info' 49 | private String[] content_type_info = new String[]{'content','http://www.w3.org/2001/XMLSchema','base64Binary','0','1','false'}; 50 | Add 'content' after 'fullName' in the field_order_type_info String array, e.g. 51 | private String[] field_order_type_info = new String[]{'fullName', 'content', 'apiVersion','description','label','packageVersions'}; 52 | - Patches the readMetadata operaton with a revised version returning IReadResult 53 | (this supports the polymorphic responses returned by the readMetadata operation) 54 | - Injects IReadResult and IReadResultResponse interfaces 55 | - Injects implementations of each of these interfaces to support the revised readMetadata option 56 | **/ 57 | 58 | /** 59 | * See the README file for instructions on how to use this class should 60 | * should you want to generate your own MetadataService.cls instead of using the one supplied 61 | **/ 62 | public with sharing class MetadataServicePatcher { 63 | 64 | private static final String API_VERSION = '42.0'; 65 | 66 | // List of classes to modify so that they extend appropirte base class (parse WSDL in future?) 67 | private static final Map METADATA_TYPES = 68 | new Map { 69 | 'CustomSite' => 'Metadata', 70 | 'ListView' => 'Metadata', 71 | 'InstalledPackage' => 'Metadata', 72 | 'CustomField' => 'Metadata', 73 | 'FieldSet' => 'Metadata', 74 | 'PicklistValue' => 'Metadata', 75 | 'RecordType' => 'Metadata', 76 | 'WebLink' => 'Metadata', 77 | 'AddressSettings' => 'Metadata', 78 | 'CaseSettings' => 'Metadata', 79 | 'CustomObject' => 'Metadata', 80 | 'Layout' => 'Metadata', 81 | 'EmailTemplate' => 'MetadataWithContent', 82 | 'Scontrol' => 'MetadataWithContent', 83 | 'ApexPage' => 'MetadataWithContent', 84 | 'ApexComponent' => 'MetadataWithContent', 85 | 'ApexClass' => 'MetadataWithContent', 86 | 'ApexTrigger' => 'MetadataWithContent', 87 | 'StaticResource' => 'MetadataWithContent', 88 | 'Document' => 'MetadataWithContent', 89 | 'CustomLabels' => 'Metadata', 90 | 'CustomLabel' => 'Metadata', 91 | 'AccountSettings' => 'Metadata', 92 | 'Queue' => 'Metadata', 93 | 'CustomDataType' => 'Metadata', 94 | 'ExternalDataSource' => 'Metadata', 95 | 'Group_x' => 'Metadata', 96 | 'BusinessProcess' => 'Metadata', 97 | 'CompactLayout' => 'Metadata', 98 | 'SharingReason' => 'Metadata', 99 | 'ValidationRule' => 'Metadata', 100 | 'WebLink' => 'Metadata', 101 | 'ReportType' => 'Metadata', 102 | 'Report' => 'Metadata', 103 | 'Dashboard' => 'Metadata', 104 | 'AnalyticSnapshot' => 'Metadata', 105 | 'AnalyticSnapshot' => 'Metadata', 106 | 'CustomPageWebLink' => 'Metadata', 107 | 'QuickAction' => 'Metadata', 108 | 'FlexiPage' => 'Metadata', 109 | 'CustomTab' => 'Metadata', 110 | 'CustomApplicationComponent' => 'Metadata', 111 | 'CustomApplication' => 'Metadata', 112 | 'Portal' => 'Metadata', 113 | 'Letterhead' => 'Metadata', 114 | 'Flow' => 'Metadata', 115 | 'Workflow' => 'Metadata', 116 | 'WorkflowRule' => 'Metadata', 117 | 'AssignmentRules' => 'Metadata', 118 | 'AssignmentRule' => 'Metadata', 119 | 'AutoResponseRules' => 'Metadata', 120 | 'AutoResponseRule' => 'Metadata', 121 | 'EscalationRules' => 'Metadata', 122 | 'EscalationRule' => 'Metadata', 123 | 'PostTemplate' => 'Metadata', 124 | 'ApprovalProcess' => 'Metadata', 125 | 'HomePageComponent' => 'Metadata', 126 | 'HomePageLayout' => 'Metadata', 127 | 'CustomObjectTranslation' => 'Metadata', 128 | 'Translations' => 'Metadata', 129 | 'Profile' => 'Metadata', 130 | 'PermissionSet' => 'Metadata', 131 | 'DataCategoryGroup' => 'Metadata', 132 | 'RemoteSiteSetting' => 'Metadata', 133 | 'Package_x' => 'Metadata', 134 | 'AuthProvider' => 'Metadata', 135 | 'CustomSite' => 'Metadata', 136 | 'KnowledgeSettings' => 'Metadata', 137 | 'SharingSet' => 'Metadata', 138 | 'SecuritySettings' => 'Metadata', 139 | 'IdeasSettings' => 'Metadata', 140 | 'ChatterAnswersSettings' => 'Metadata', 141 | 'Community' => 'Metadata', 142 | 'ActivitiesSettings' => 'Metadata', 143 | 'ContractSettings' => 'Metadata', 144 | 'OrderSettings' => 'Metadata', 145 | 'OpportunitySettings' => 'Metadata', 146 | 'ProductSettings' => 'Metadata', 147 | 'QuoteSettings' => 'Metadata', 148 | 'CallCenter' => 'Metadata', 149 | 'EntitlementProcess' => 'Metadata', 150 | 'MilestoneType' => 'Metadata', 151 | 'EntitlementTemplate' => 'Metadata', 152 | 'EntitlementSettings' => 'Metadata', 153 | 'BusinessHoursSettings' => 'Metadata', 154 | 'BusinessHoursEntry' => 'Metadata', 155 | 'CaseSettings' => 'Metadata', 156 | 'ConnectedApp' => 'Metadata', 157 | 'AppMenu' => 'Metadata', 158 | 'MobileSettings' => 'Metadata', 159 | 'Network' => 'Metadata', 160 | 'CompanySettings' => 'Metadata', 161 | 'ForecastingSettings' => 'Metadata', 162 | 'SamlSsoConfig' => 'Metadata', 163 | 'LiveAgentSettings' => 'Metadata', 164 | 'Skill' => 'Metadata', 165 | 'LiveChatDeployment' => 'Metadata', 166 | 'LiveChatButton' => 'Metadata', 167 | 'LiveChatAgentConfig' => 'Metadata', 168 | 'SynonymDictionary' => 'Metadata', 169 | 'Folder' => 'Metadata', 170 | 'ReportFolder' => 'Folder', 171 | 'DashboardFolder' => 'Folder', 172 | 'DocumentFolder' => 'Folder', 173 | 'EmailFolder' => 'Folder', 174 | 'RoleOrTerritory' => 'Metadata', 175 | 'WorkflowAction' => 'Metadata', 176 | 'SiteDotCom' => 'MetadataWithContent', 177 | 'WorkflowTask' => 'WorkflowAction', 178 | 'WorkflowSend' => 'WorkflowAction', 179 | 'WorkflowOutboundMessage' => 'WorkflowAction', 180 | 'WorkflowKnowledgePublish' => 'WorkflowAction', 181 | 'WorkflowFieldUpdate' => 'WorkflowAction', 182 | 'WorkflowAlert' => 'WorkflowAction', 183 | 'WorkflowAction' => 'Metadata', 184 | 'VisualizationPlugin' => 'Metadata', 185 | 'CustomMetadata' => 'Metadata', 186 | 'NameSettings' => 'Metadata', 187 | 'MarketingActionSettings' => 'Metadata', 188 | 'CustomPermission' => 'Metadata', 189 | 'AuraDefinitionBundle' => 'Metadata', 190 | 'CorsWhitelistOrigin' => 'Metadata', 191 | 'ManagedTopics' => 'Metadata', 192 | 'Territory2' => 'Metadata', 193 | 'Territory2Model' => 'Metadata', 194 | 'Territory2Settings' => 'Metadata', 195 | 'Territory2Type' => 'Metadata', 196 | 'XOrgHub' => 'Metadata', 197 | 'ActionLinkGroupTemplate' => 'Metadata', 198 | 'LicenseDefinition' => 'Metadata', 199 | 'MarketingResourceType' => 'Metadata', 200 | 'MatchingRule' => 'Metadata', 201 | 'MatchingRules' => 'Metadata', 202 | 'NamedCredential' => 'Metadata', 203 | 'PersonalJourneySettings' => 'Metadata', 204 | 'SharingRules' => 'Metadata', 205 | 'SharingBaseRule' => 'Metadata', 206 | 'SharingCriteriaRule' => 'SharingBaseRule', 207 | 'SharingOwnerRule' => 'SharingBaseRule', 208 | 'SharingTerritoryRule' => 'SharingBaseRule', 209 | 'FlowElement' => 'FlowBaseElement', 210 | 'FlowNode' => 'FlowElement', 211 | 'FlowActionCall' => 'FlowNode', 212 | 'FlowApexPluginCall' => 'FlowNode', 213 | 'FlowAssignment' => 'FlowNode', 214 | 'FlowDecision' => 'FlowNode', 215 | 'FlowLoop' => 'FlowNode', 216 | 'FlowRecordCreate' => 'FlowNode', 217 | 'FlowRecordDelete' => 'FlowNode', 218 | 'FlowRecordLookup' => 'FlowNode', 219 | 'FlowRecordUpdate' => 'FlowNode', 220 | 'FlowScreen' => 'FlowNode', 221 | 'FlowStep' => 'FlowNode', 222 | 'FlowSubflow' => 'FlowNode', 223 | 'FlowWait' => 'FlowNode', 224 | 'FlowActionCall' => 'FlowNode', 225 | 'FlowChoice' => 'FlowElement', 226 | 'FlowConstant' => 'FlowElement', 227 | 'FlowDynamicChoiceSet' => 'FlowElement', 228 | 'FlowFormula' => 'FlowElement', 229 | 'FlowRule' => 'FlowElement', 230 | 'FlowScreenField' => 'FlowElement', 231 | 'FlowTextTemplate' => 'FlowElement', 232 | 'FlowVariable' => 'FlowElement', 233 | 'FlowWaitEvent' => 'FlowElement', 234 | 'FlowActionCallInputParameter' => 'FlowBaseElement', 235 | 'FlowActionCallOutputParameter' => 'FlowBaseElement', 236 | 'FlowApexPluginCallInputParameter' => 'FlowBaseElement', 237 | 'FlowApexPluginCallOutputParameter' => 'FlowBaseElement', 238 | 'FlowAssignmentItem' => 'FlowBaseElement', 239 | 'FlowChoiceUserInput' => 'FlowBaseElement', 240 | 'FlowCondition' => 'FlowBaseElement', 241 | 'FlowConnector' => 'FlowBaseElement', 242 | 'FlowInputFieldAssignment' => 'FlowBaseElement', 243 | 'FlowOutputFieldAssignment' => 'FlowBaseElement', 244 | 'FlowRecordFilter' => 'FlowBaseElement', 245 | 'FlowSubflowInputAssignment' => 'FlowBaseElement', 246 | 'FlowSubflowOutputAssignment' => 'FlowBaseElement', 247 | 'FlowWaitEventInputParameter' => 'FlowBaseElement', 248 | 'FlowWaitEventOutputParameter' => 'FlowBaseElement', 249 | 'MetadataWithContent' => 'Metadata', 250 | 'DelegateGroup' => 'Metadata', 251 | 'EventDelivery' => 'Metadata', 252 | 'EventSubscription' => 'Metadata', 253 | 'EventType' => 'Metadata', 254 | 'Certificate' => 'MetadataWithContent', 255 | 'ModerationRule' => 'Metadata', 256 | 'WaveApplication' => 'Metadata', 257 | 'WaveDataset' => 'Metadata', 258 | 'WaveDashboard' => 'MetadataWithContent', 259 | 'WaveDataflow' => 'MetadataWithContent', 260 | 'WaveLens' => 'MetadataWithContent', 261 | 'OrgPreferenceSettings' => 'Metadata', 262 | 'SearchSettings' => 'Metadata', 263 | 'GlobalValueSet' => 'Metadata', 264 | 'GlobalPicklistValue' => 'Metadata', 265 | 'PicklistValue' => 'GlobalPicklistValue', 266 | 'StandardValueSet' => 'Metadata', 267 | 'StandardValue' => 'CustomValue', 268 | 'CustomValue' => 'Metadata', 269 | 'ApexTestSuite' => 'Metadata', 270 | 'ChannelLayout' => 'Metadata', 271 | 'ContentAsset' => 'Metadata', 272 | 'EmailServicesFunction' => 'Metadata', 273 | 'EmbeddedServiceBranding' => 'Metadata', 274 | 'EmbeddedServiceConfig' => 'Metadata', 275 | 'EmbeddedServiceLiveAgent' => 'Metadata', 276 | 'CaseSubjectParticle' => 'Metadata', 277 | 'NetworkBranding' => 'MetadataWithContent', 278 | 'SocialCustomerServiceSettings' => 'Metadata', 279 | 'TopicsForObjects' => 'Metadata', 280 | 'BrandingSet' => 'Metadata', 281 | 'ProfilePasswordPolicy' => 'Metadata', 282 | 'ProfileSessionSetting' => 'Metadata', 283 | 'CspTrustedSite' => 'Metadata', 284 | 'EclairGeoData' => 'MetadataWithContent', 285 | 'ExternalServiceRegistration' => 'Metadata', 286 | 'FileUploadAndDownloadSecuritySettings' => 'Metadata', 287 | 'LeadConvertSettings' => 'Metadata', 288 | 'UserCriteria' => 'Metadata', 289 | 'Wavexmd' => 'Metadata' 290 | }; // TODO: Inheritance modifications for Role and Custom Shortcut 291 | 292 | // List of base types to prescan for merging into derived types 293 | private static final Set METADATA_BASE_TYPES = new Set(METADATA_TYPES.values()); 294 | 295 | public static void patch() 296 | { 297 | // Query the Apex Class generated by the platform WSDL to Apex generator 298 | ApexClass apexClass = 299 | [select Id, Body 300 | from ApexClass 301 | where Name = 'MetadataServiceImported']; 302 | 303 | // Read base types 304 | Map> typeBodyByBaseClass = new Map>(); 305 | LineReader lineReader = new LineReader(apexClass.Body); 306 | while(lineReader.hasNext()) 307 | { 308 | // Read line 309 | String line = lineReader.next(); 310 | String trimmedLine = line.trim(); 311 | // Class definition? 312 | if(trimmedLine.startsWith('public class')) 313 | { 314 | List parts = trimmedLine.split(' '); 315 | String className = parts[2]; 316 | // Capture the body of this base type to later inject into another deriving type 317 | if(METADATA_BASE_TYPES.contains(className)) { 318 | List baseTypeLines = new List(); 319 | typeBodyByBaseClass.put(className, baseTypeLines); 320 | // Move forward until field_order_type_info member 321 | while(lineReader.hasNext()) 322 | { 323 | line = (String) lineReader.next(); 324 | // Adjust class name? 325 | if(line.contains('MetadataServiceImported')) 326 | line = line.replace('MetadataServiceImported', 'MetadataService'); 327 | // Recording content of type for inclusion in deriving types 328 | baseTypeLines.add(line); 329 | // Stop here 330 | if(line.trim().startsWith('private String[] field_order_type_info')) 331 | break; 332 | } 333 | } 334 | } 335 | } 336 | 337 | // Process and scan for lines to modify and/or insert 338 | lineReader = new LineReader(apexClass.Body); 339 | List newLines = new List(); 340 | addCopyright(newLines); 341 | newLines.add(''); 342 | newLines.add('//Patched by MetadataServicePatcher v' + API_VERSION + ' ' + System.today()); 343 | newLines.add(''); 344 | while(lineReader.hasNext()) 345 | { 346 | // Read line 347 | String line = lineReader.next(); 348 | String trimmedLine = line.trim(); 349 | // Adjust class name? 350 | if(trimmedLine.contains('MetadataServiceImported')) 351 | line = line.replace('MetadataServiceImported', 'MetadataService'); 352 | // Adjust end point logic? 353 | if(trimmedLine.startsWith('public String endpoint_x')) 354 | line = ' public String endpoint_x = URL.getOrgDomain().toExternalForm() + \'/services/Soap/m/' + API_VERSION + '\';'; 355 | // Adjust update_x method name? 356 | else if(trimmedLine.contains('update_x(')) 357 | line = line.replace('update_x', 'updateMetadata'); 358 | // Adjust delete_x method name? 359 | else if(trimmedLine.contains('delete_x(')) 360 | line = line.replace('delete_x', 'deleteMetadata'); 361 | // Adjust retrieve_x method name? 362 | else if(trimmedLine.contains('retrieve_x(')) 363 | line = line.replace('retrieve_x', 'retrieve'); 364 | // Make Metadata virtual? 365 | else if(trimmedLine.startsWith('public class Metadata ')) { 366 | line = line.replace('public class', 'public virtual class'); 367 | newLines.add(line); 368 | while(lineReader.hasNext()) 369 | { 370 | line = (String) lineReader.next(); 371 | trimmedLine = line.trim(); 372 | // Skip these, not needed as duplciated in derived classes and cause JSON serialise issues for types 373 | if(line.contains('fullName_type_info') || 374 | line.contains('apex_schema_type_info') || 375 | line.contains('field_order_type_info')) 376 | continue; 377 | newLines.add(line); 378 | if(trimmedLine == '}') 379 | break; 380 | } 381 | continue; 382 | } 383 | // Add interfaces to read? 384 | else if(trimmedLine.startsWith('public class ReadResult')) 385 | { 386 | newlines.add(' public interface IReadResult {'); 387 | newlines.add(' MetadataService.Metadata[] getRecords();'); 388 | newlines.add(' }'); 389 | newlines.add(' public interface IReadResponseElement {'); 390 | newlines.add(' IReadResult getResult();'); 391 | newlines.add(' }'); 392 | for(String metadataType : METADATA_TYPES.keySet()) 393 | { 394 | // Only emit for types extending Metadata or MetadataWithContent 395 | String baseClass = METADATA_TYPES.get(metadataType); 396 | while(baseClass!=null) { 397 | if(baseClass == 'Metadata' || baseClass=='MetadataWithContent') 398 | break; 399 | baseClass = METADATA_TYPES.get(baseClass); 400 | } 401 | if(baseClass == 'Metadata' || baseClass=='MetadataWithContent') { 402 | String apexClassType = metadataType; 403 | if(metadataType == 'Group_x') 404 | apexClassType = 'Group'; 405 | else if(metadataType == 'Package_x') 406 | apexClassType = 'Package'; 407 | newlines.add(' public class Read'+apexClassType+'Result implements IReadResult {'); 408 | newlines.add(' public MetadataService.'+metadataType+'[] records;'); 409 | newlines.add(' public MetadataService.Metadata[] getRecords() { return records; }'); 410 | newlines.add(' private String[] records_type_info = new String[]{\'records\',\'http://soap.sforce.com/2006/04/metadata\',null,\'0\',\'-1\',\'false\'};'); 411 | newlines.add(' private String[] apex_schema_type_info = new String[]{\'http://soap.sforce.com/2006/04/metadata\',\'true\',\'false\'};'); 412 | newlines.add(' private String[] field_order_type_info = new String[]{\'records\'};'); 413 | newlines.add(' }'); 414 | newlines.add(' public class read'+apexClassType+'Response_element implements IReadResponseElement {'); 415 | newlines.add(' public MetadataService.Read'+apexClassType+'Result result;'); 416 | newlines.add(' public IReadResult getResult() { return result; }'); 417 | newlines.add(' private String[] result_type_info = new String[]{\'result\',\'http://soap.sforce.com/2006/04/metadata\',null,\'1\',\'1\',\'false\'};'); 418 | newlines.add(' private String[] apex_schema_type_info = new String[]{\'http://soap.sforce.com/2006/04/metadata\',\'true\',\'false\'};'); 419 | newlines.add(' private String[] field_order_type_info = new String[]{\'result\'};'); 420 | newlines.add(' }'); 421 | } 422 | } 423 | } 424 | // readMetadata method? 425 | else if(trimmedLine.startsWith('public MetadataServiceImported.ReadResult readMetadata(String type_x,String[] fullNames) {')) 426 | { 427 | // Swallow up the generated readMetadata method 428 | while(lineReader.hasNext()) 429 | { 430 | line = (String) lineReader.next(); 431 | trimmedLine = line.trim(); 432 | if(trimmedLine == '}') 433 | break; 434 | } 435 | // Emit the new readMetadata method returnin the IReadResult interface 436 | newlines.add(' public MetadataService.IReadResult readMetadata(String type_x,String[] fullNames) {'); 437 | newlines.add(' MetadataService.readMetadata_element request_x = new MetadataService.readMetadata_element();'); 438 | newlines.add(' request_x.type_x = type_x;'); 439 | newlines.add(' request_x.fullNames = fullNames;'); 440 | newlines.add(' MetadataService.IReadResponseElement response_x;'); 441 | newlines.add(' Map response_map_x = new Map();'); 442 | newlines.add(' response_map_x.put(\'response_x\', response_x);'); 443 | newlines.add(' WebServiceCallout.invoke('); 444 | newlines.add(' this,'); 445 | newlines.add(' request_x,'); 446 | newlines.add(' response_map_x,'); 447 | newlines.add(' new String[]{endpoint_x,'); 448 | newlines.add(' \'\','); 449 | newlines.add(' \'http://soap.sforce.com/2006/04/metadata\','); 450 | newlines.add(' \'readMetadata\','); 451 | newlines.add(' \'http://soap.sforce.com/2006/04/metadata\','); 452 | newlines.add(' \'readMetadataResponse\','); 453 | newlines.add(' \'MetadataService.read\' + type_x + \'Response_element\'}'); 454 | newlines.add(' );'); 455 | newlines.add(' response_x = response_map_x.get(\'response_x\');'); 456 | newlines.add(' return response_x.getResult();'); 457 | } 458 | // Class definition? 459 | else if(trimmedLine.startsWith('public class')) 460 | { 461 | List parts = trimmedLine.split(' '); 462 | String className = parts[2]; 463 | // Processing a base type? 464 | if(METADATA_BASE_TYPES.contains(className)) { 465 | String extendsClassName = METADATA_TYPES.get(className); 466 | line = line.replace('public class ' + className, 467 | extendsClassName!=null ? 468 | 'public virtual class ' + className + ' extends ' + extendsClassName : 469 | 'public virtual class ' + className); 470 | newLines.add(line); 471 | while(lineReader.hasNext()) 472 | { 473 | line = (String) lineReader.next(); 474 | trimmedLine = line.trim(); 475 | // Skip these, not needed as duplciated in derived classes and cause JSON serialise issues for types 476 | if(trimmedLine.startsWith('private String[]')) 477 | continue; 478 | newLines.add(line); 479 | if(trimmedLine == '}') 480 | break; 481 | } 482 | continue; 483 | } 484 | // Processing a top level type which has a base type? 485 | else if(METADATA_TYPES.containsKey(className)) 486 | { 487 | // Adjust class to extend base class and add base class members (XML serialiser does not support inheritance) 488 | String extendsClassName = METADATA_TYPES.get(className); 489 | line = line.replace('public class ' + className, 490 | METADATA_BASE_TYPES.contains(className) ? 491 | 'public virtual class ' + className + ' extends ' + extendsClassName : 492 | 'public class ' + className + ' extends ' + extendsClassName); 493 | newLines.add(line); 494 | newLines.add(' public String type = \'' + className + '\';'); 495 | // Keep going all the way down to the last base class 496 | List fieldOrderTypeInfoFromBaseType = new List(); 497 | List baseTypes = new List(); 498 | String baseClassName = extendsClassName; 499 | while (baseClassName!=null) { 500 | baseTypes.add(baseClassName); 501 | baseClassName = METADATA_TYPES.get(baseClassName); 502 | } 503 | // Merge base class members from the base class upwards 504 | for(Integer idx = baseTypes.size()-1; ; idx--) { 505 | baseClassName = baseTypes[idx]; 506 | for(String baseClassLine : typeBodyByBaseClass.get(baseClassName)) { 507 | // Skip this base class member as the top level derived type will have one 508 | if(baseClassLine.contains('apex_schema_type_info')) 509 | continue; 510 | // Extract the field order type info list to add to the dervived type one 511 | if(baseClassLine.contains('field_order_type_info')) 512 | { 513 | // Extract the list of base type fields 514 | if(baseClassLine.indexOf('\'')>0) { 515 | fieldOrderTypeInfoFromBaseType.add( 516 | baseClassLine.substring( 517 | baseClassLine.indexOf('\''), 518 | baseClassLine.lastIndexOf('\'')+1)); 519 | } 520 | // Skip it as the top level derived type will have one 521 | continue; 522 | } 523 | newLines.add(baseClassLine); 524 | } 525 | if(idx==0) 526 | break; 527 | } 528 | // Move forward until field_order_type_info member 529 | while(lineReader.hasNext()) 530 | { 531 | line = (String) lineReader.next(); 532 | trimmedLine = line.trim(); 533 | // Adjust class name? 534 | if(trimmedLine.contains('MetadataServiceImported')) 535 | line = line.replace('MetadataServiceImported', 'MetadataService'); 536 | // Adjust the fields listed in the field_order_type_info metadata 537 | if(trimmedLine.startsWith('private String[] field_order_type_info')) 538 | { 539 | // Add type info descriptors and adjust field_order_type_info list 540 | newLines.add(' private String[] type_att_info = new String[]{\'xsi:type\'};'); 541 | String newFieldOrderType = 542 | fieldOrderTypeInfoFromBaseType.size()>0 ? 543 | String.join(fieldOrderTypeInfoFromBaseType, ',') : ''; 544 | if(line.endsWith('new String[]{};')) 545 | line = line.replace('new String[]{', 'new String[]{' + newFieldOrderType); 546 | else 547 | line = line.replace('new String[]{', 'new String[]{' + newFieldOrderType + ', '); 548 | newLines.add(line); 549 | break; 550 | } 551 | newLines.add(line); 552 | } 553 | continue; 554 | } 555 | } 556 | newLines.add(line); 557 | } 558 | String patchClass = String.join(newLines, '\n'); 559 | 560 | // Upload the generated code to a Document 561 | // (this can be included in a MavensMate or Eclipse project for easy access via Refresh from Server) 562 | List docs = [select Id from Document where DeveloperName = 'MetadataServicePatchedCopy']; 563 | Document generatedCode = docs.size()>0 ? docs[0] : new Document(); 564 | generatedCode.Name = 'MetadataService'; 565 | generatedCode.Body = Blob.valueOf(patchClass); 566 | generatedCode.DeveloperName = 'MetadataServicePatchedCopy'; 567 | generatedCode.FolderId = [select Id from Folder where DeveloperName = 'MetadataServicePatcher'].Id; 568 | if(generatedCode.Id == null) 569 | insert generatedCode; 570 | else 571 | update generatedCode; 572 | } 573 | 574 | public class PatchException extends Exception { } 575 | 576 | /** 577 | * Utility class to iterate over lines in Apex source code 578 | **/ 579 | public class LineReader 580 | implements Iterator, Iterable 581 | { 582 | private String LF = '\n'; 583 | 584 | private String textData; 585 | 586 | public LineReader(String textData) 587 | { 588 | this.textData = textData; 589 | } 590 | 591 | public Boolean hasNext() 592 | { 593 | return textData.length() > 0 ? true : false; 594 | } 595 | 596 | public String next() 597 | { 598 | String row = null; 599 | Integer endPos = textData.indexOf(LF); 600 | if(endPos == -1) 601 | { 602 | row = textData; 603 | textData = ''; 604 | } 605 | else 606 | { 607 | row = textData.subString(0, endPos); 608 | textData = textData.subString(endPos + LF.length(), textData.length()); 609 | } 610 | return row; 611 | } 612 | 613 | public Iterator Iterator() 614 | { 615 | return this; 616 | } 617 | } 618 | 619 | private static void addCopyright(List lines) 620 | { 621 | lines.add('/**'); 622 | lines.add(' * Copyright (c), FinancialForce.com, inc'); 623 | lines.add(' * All rights reserved.'); 624 | lines.add(' *'); 625 | lines.add(' * Redistribution and use in source and binary forms, with or without modification,'); 626 | lines.add(' * are permitted provided that the following conditions are met:'); 627 | lines.add(' *'); 628 | lines.add(' * - Redistributions of source code must retain the above copyright notice,'); 629 | lines.add(' * this list of conditions and the following disclaimer.'); 630 | lines.add(' * - Redistributions in binary form must reproduce the above copyright notice,'); 631 | lines.add(' * this list of conditions and the following disclaimer in the documentation'); 632 | lines.add(' * and/or other materials provided with the distribution.'); 633 | lines.add(' * - Neither the name of the FinancialForce.com, inc nor the names of its contributors'); 634 | lines.add(' * may be used to endorse or promote products derived from this software without'); 635 | lines.add(' * specific prior written permission.'); 636 | lines.add(' *'); 637 | lines.add(' * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND'); 638 | lines.add(' * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES'); 639 | lines.add(' * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL'); 640 | lines.add(' * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,'); 641 | lines.add(' * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS'); 642 | lines.add(' * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY'); 643 | lines.add(' * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)'); 644 | lines.add(' * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.'); 645 | lines.add('**/'); 646 | } 647 | } 648 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataServicePatcher.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataServiceTest.cls: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2012, FinancialForce.com, inc 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * - Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * - Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * - Neither the name of the FinancialForce.com, inc nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software without 15 | * specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 20 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 23 | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | **/ 26 | 27 | /** 28 | * This is a dummy test class to obtain 100% coverage for the generated WSDL2Apex code, it is not a funcitonal test class 29 | **/ 30 | @isTest 31 | private class MetadataServiceTest 32 | { 33 | /** 34 | * Dummy Metadata API web service mock class (see MetadataCreateJobTest.cls for a better example) 35 | **/ 36 | private class WebServiceMockImpl implements WebServiceMock 37 | { 38 | public void doInvoke( 39 | Object stub, Object request, Map response, 40 | String endpoint, String soapAction, String requestName, 41 | String responseNS, String responseName, String responseType) 42 | { 43 | if(request instanceof MetadataService.retrieve_element) 44 | response.put('response_x', new MetadataService.retrieveResponse_element()); 45 | else if(request instanceof MetadataService.checkDeployStatus_element) 46 | response.put('response_x', new MetadataService.checkDeployStatusResponse_element()); 47 | else if(request instanceof MetadataService.listMetadata_element) 48 | response.put('response_x', new MetadataService.listMetadataResponse_element()); 49 | else if(request instanceof MetadataService.checkRetrieveStatus_element) 50 | response.put('response_x', new MetadataService.checkRetrieveStatusResponse_element()); 51 | else if(request instanceof MetadataService.describeMetadata_element) 52 | response.put('response_x', new MetadataService.describeMetadataResponse_element()); 53 | else if(request instanceof MetadataService.deploy_element) 54 | response.put('response_x', new MetadataService.deployResponse_element()); 55 | else if(request instanceof MetadataService.updateMetadata_element) 56 | response.put('response_x', new MetadataService.updateMetadataResponse_element()); 57 | else if(request instanceof MetadataService.renameMetadata_element) 58 | response.put('response_x', new MetadataService.renameMetadataResponse_element()); 59 | else if(request instanceof MetadataService.cancelDeploy_element) 60 | response.put('response_x', new MetadataService.cancelDeployResponse_element()); 61 | else if(request instanceof MetadataService.deleteMetadata_element) 62 | response.put('response_x', new MetadataService.deleteMetadataResponse_element()); 63 | else if(request instanceof MetadataService.upsertMetadata_element) 64 | response.put('response_x', new MetadataService.upsertMetadataResponse_element()); 65 | else if(request instanceof MetadataService.createMetadata_element) 66 | response.put('response_x', new MetadataService.createMetadataResponse_element()); 67 | else if(request instanceof MetadataService.deployRecentValidation_element) 68 | response.put('response_x', new MetadataService.deployRecentValidationResponse_element()); 69 | else if(request instanceof MetadataService.describeValueType_element) 70 | response.put('response_x', new MetadataService.describeValueTypeResponse_element()); 71 | else if(request instanceof MetadataService.checkRetrieveStatus_element) 72 | response.put('response_x', new MetadataService.checkRetrieveStatusResponse_element()); 73 | return; 74 | } 75 | } 76 | 77 | @IsTest 78 | private static void coverGeneratedCodeCRUDOperations() 79 | { 80 | // Null Web Service mock implementation 81 | System.Test.setMock(WebServiceMock.class, new WebServiceMockImpl()); 82 | // Only required to workaround a current code coverage bug in the platform 83 | MetadataService metaDataService = new MetadataService(); 84 | // Invoke operations 85 | Test.startTest(); 86 | MetadataService.MetadataPort metaDataPort = new MetadataService.MetadataPort(); 87 | Test.stopTest(); 88 | } 89 | 90 | @IsTest 91 | private static void coverGeneratedCodeFileBasedOperations1() 92 | { 93 | // Null Web Service mock implementation 94 | System.Test.setMock(WebServiceMock.class, new WebServiceMockImpl()); 95 | // Only required to workaround a current code coverage bug in the platform 96 | MetadataService metaDataService = new MetadataService(); 97 | // Invoke operations 98 | Test.startTest(); 99 | MetadataService.MetadataPort metaDataPort = new MetadataService.MetadataPort(); 100 | metaDataPort.retrieve(null); 101 | metaDataPort.checkDeployStatus(null, false); 102 | metaDataPort.listMetadata(null, null); 103 | metaDataPort.describeMetadata(null); 104 | metaDataPort.deploy(null, null); 105 | metaDataPort.checkDeployStatus(null, false); 106 | metaDataPort.updateMetadata(null); 107 | metaDataPort.renameMetadata(null, null, null); 108 | metaDataPort.cancelDeploy(null); 109 | Test.stopTest(); 110 | } 111 | 112 | @IsTest 113 | private static void coverGeneratedCodeFileBasedOperations2() 114 | { 115 | // Null Web Service mock implementation 116 | System.Test.setMock(WebServiceMock.class, new WebServiceMockImpl()); 117 | // Only required to workaround a current code coverage bug in the platform 118 | MetadataService metaDataService = new MetadataService(); 119 | // Invoke operations 120 | Test.startTest(); 121 | MetadataService.MetadataPort metaDataPort = new MetadataService.MetadataPort(); 122 | metaDataPort.deleteMetadata(null, null); 123 | metaDataPort.upsertMetadata(null); 124 | metaDataPort.createMetadata(null); 125 | metaDataPort.deployRecentValidation(null); 126 | metaDataPort.describeValueType(null); 127 | metaDataPort.checkRetrieveStatus(null, null); 128 | Test.stopTest(); 129 | } 130 | 131 | @IsTest 132 | private static void coverGeneratedCodeTypes() 133 | { 134 | // Reference types 135 | Test.startTest(); 136 | new MetadataService(); 137 | new MetadataService.listMetadataResponse_element(); 138 | new MetadataService.WorkflowRule(); 139 | new MetadataService.RecordTypeTranslation(); 140 | new MetadataService.checkDeployStatus_element(); 141 | new MetadataService.CodeCoverageWarning(); 142 | new MetadataService.FlowApexPluginCall(); 143 | new MetadataService.FlowInputValidationRule(); 144 | new MetadataService.FlowFormula(); 145 | new MetadataService.PasswordPolicies(); 146 | new MetadataService.QueueSobject(); 147 | new MetadataService.PicklistValueTranslation(); 148 | new MetadataService.CustomDataType(); 149 | new MetadataService.PrimaryTabComponents(); 150 | new MetadataService.WorkflowEmailRecipient(); 151 | new MetadataService.DescribeMetadataResult(); 152 | new MetadataService.RecordType(); 153 | new MetadataService.Scontrol(); 154 | new MetadataService.DashboardComponent(); 155 | new MetadataService.FilterItem(); 156 | new MetadataService.Profile(); 157 | new MetadataService.ReportFilter(); 158 | new MetadataService.PermissionSetApexClassAccess(); 159 | new MetadataService.LogInfo(); 160 | new MetadataService.Layout(); 161 | new MetadataService.WebLink(); 162 | new MetadataService.WorkflowTaskTranslation(); 163 | new MetadataService.FlowElement(); 164 | new MetadataService.ObjectNameCaseValue(); 165 | new MetadataService.FlowInputFieldAssignment(); 166 | new MetadataService.CustomDataTypeTranslation(); 167 | new MetadataService.DashboardComponentSection(); 168 | new MetadataService.ReportTypeColumn(); 169 | new MetadataService.CallOptions_element(); 170 | new MetadataService.CustomFieldTranslation(); 171 | new MetadataService.AnalyticSnapshot(); 172 | new MetadataService.FlowRule(); 173 | new MetadataService.FlowRecordUpdate(); 174 | new MetadataService.CustomSite(); 175 | new MetadataService.ReportBlockInfo(); 176 | new MetadataService.describeMetadataResponse_element(); 177 | new MetadataService.ScontrolTranslation(); 178 | new MetadataService.DeployMessage(); 179 | new MetadataService.FlowSubflowInputAssignment(); 180 | new MetadataService.Group_x(); 181 | new MetadataService.ReportColumn(); 182 | new MetadataService.ReportType(); 183 | new MetadataService.CustomPageWebLink(); 184 | new MetadataService.CodeCoverageResult(); 185 | new MetadataService.ApexComponent(); 186 | new MetadataService.WorkflowKnowledgePublish(); 187 | new MetadataService.NetworkAccess(); 188 | new MetadataService.Workflow(); 189 | new MetadataService.RecordTypePicklistValue(); 190 | new MetadataService.describeMetadata_element(); 191 | new MetadataService.DashboardFilterColumn(); 192 | new MetadataService.FlowChoice(); 193 | new MetadataService.ReportParam(); 194 | new MetadataService.RoleOrTerritory(); 195 | new MetadataService.FlowStep(); 196 | new MetadataService.FlowApexPluginCallInputParameter(); 197 | new MetadataService.WorkflowActionReference(); 198 | new MetadataService.ProfileObjectPermissions(); 199 | new MetadataService.Role(); 200 | new MetadataService.RetrieveResult(); 201 | new MetadataService.SecuritySettings(); 202 | new MetadataService.WorkflowTimeTrigger(); 203 | new MetadataService.retrieve_element(); 204 | new MetadataService.DescribeMetadataObject(); 205 | new MetadataService.DashboardFilterOption(); 206 | new MetadataService.LayoutColumn(); 207 | new MetadataService.WorkflowOutboundMessage(); 208 | new MetadataService.RunTestSuccess(); 209 | new MetadataService.Queue(); 210 | new MetadataService.ListViewFilter(); 211 | new MetadataService.CustomField(); 212 | new MetadataService.WorkflowTask(); 213 | new MetadataService.deployResponse_element(); 214 | new MetadataService.DataCategory(); 215 | new MetadataService.FlowOutputFieldAssignment(); 216 | new MetadataService.EmailTemplate(); 217 | new MetadataService.ReportAggregateReference(); 218 | new MetadataService.ObjectUsage(); 219 | new MetadataService.FileProperties(); 220 | new MetadataService.CustomTabTranslation(); 221 | new MetadataService.BusinessProcess(); 222 | new MetadataService.Flow(); 223 | new MetadataService.PermissionSet(); 224 | new MetadataService.PermissionSetObjectPermissions(); 225 | new MetadataService.ReportCrossFilter(); 226 | new MetadataService.Report(); 227 | new MetadataService.FlowSubflowOutputAssignment(); 228 | new MetadataService.ListView(); 229 | new MetadataService.FlowRecordCreate(); 230 | new MetadataService.DashboardTableColumn(); 231 | new MetadataService.AsyncResult(); 232 | new MetadataService.ArticleTypeChannelDisplay(); 233 | new MetadataService.checkRetrieveStatus_element(); 234 | new MetadataService.ProfileLayoutAssignment(); 235 | new MetadataService.ReportFolder(); 236 | new MetadataService.FlowTextTemplate(); 237 | new MetadataService.RelatedListItem(); 238 | new MetadataService.FlowNode(); 239 | new MetadataService.RetrieveRequest(); 240 | new MetadataService.ListMetadataQuery(); 241 | new MetadataService.FlowConnector(); 242 | new MetadataService.CustomApplicationComponent(); 243 | new MetadataService.FlowRecordLookup(); 244 | new MetadataService.FieldSet(); 245 | new MetadataService.ProfileApexClassAccess(); 246 | new MetadataService.DebuggingHeader_element(); 247 | new MetadataService.CustomDataTypeComponentTranslation(); 248 | new MetadataService.FlowRecordDelete(); 249 | new MetadataService.FlowDecision(); 250 | new MetadataService.ReportTypeSectionTranslation(); 251 | new MetadataService.IpRange(); 252 | new MetadataService.FlowApexPluginCallOutputParameter(); 253 | new MetadataService.ReportBucketField(); 254 | new MetadataService.CustomLabel(); 255 | new MetadataService.Attachment(); 256 | new MetadataService.SharingRules(); 257 | new MetadataService.CustomConsoleComponents(); 258 | new MetadataService.Portal(); 259 | //new MetadataService.DomainWhitelist(); 260 | new MetadataService.ChartSummary(); 261 | new MetadataService.RunTestFailure(); 262 | new MetadataService.Territory(); 263 | new MetadataService.SharedTo(); 264 | new MetadataService.FlowRecordFilter(); 265 | new MetadataService.SubtabComponents(); 266 | new MetadataService.FlowScreen(); 267 | new MetadataService.WorkflowAlert(); 268 | new MetadataService.Picklist(); 269 | new MetadataService.ReportLayoutSection(); 270 | new MetadataService.SummaryLayoutItem(); 271 | new MetadataService.LayoutSection(); 272 | new MetadataService.ReportTimeFrameFilter(); 273 | new MetadataService.LayoutSectionTranslation(); 274 | new MetadataService.DataCategoryGroup(); 275 | new MetadataService.listMetadata_element(); 276 | new MetadataService.ValidationRule(); 277 | new MetadataService.WorkspaceMapping(); 278 | new MetadataService.MetadataWithContent(); 279 | new MetadataService.ValidationRuleTranslation(); 280 | new MetadataService.Metadata(); 281 | new MetadataService.ReportBucketFieldValue(); 282 | new MetadataService.HomePageLayout(); 283 | new MetadataService.FlowSubflow(); 284 | new MetadataService.FlowScreenField(); 285 | new MetadataService.SiteWebAddress(); 286 | new MetadataService.RetrieveMessage(); 287 | new MetadataService.Dashboard(); 288 | new MetadataService.EmailFolder(); 289 | new MetadataService.SessionHeader_element(); 290 | new MetadataService.SummaryLayout(); 291 | new MetadataService.FlowCondition(); 292 | new MetadataService.DeployOptions(); 293 | new MetadataService.FlowAssignment(); 294 | new MetadataService.ProfileApplicationVisibility(); 295 | //new MetadataService.CustomApplicationComponents(); 296 | new MetadataService.FlowElementReferenceOrValue(); 297 | new MetadataService.EntitlementTemplate(); 298 | new MetadataService.ProfileTabVisibility(); 299 | new MetadataService.ActionOverride(); 300 | //new MetadataService.WorkspaceMappings(); 301 | new MetadataService.WorkflowAction(); 302 | new MetadataService.DashboardFolder(); 303 | new MetadataService.PermissionSetApexPageAccess(); 304 | new MetadataService.LayoutTranslation(); 305 | new MetadataService.CustomObject(); 306 | new MetadataService.Translations(); 307 | new MetadataService.ApexTrigger(); 308 | new MetadataService.ReportTypeTranslation(); 309 | new MetadataService.FlowAssignmentItem(); 310 | new MetadataService.CustomApplicationTranslation(); 311 | new MetadataService.CustomLabels(); 312 | new MetadataService.PackageTypeMembers(); 313 | new MetadataService.PicklistValue(); 314 | new MetadataService.RemoteSiteSetting(); 315 | new MetadataService.deploy_element(); 316 | new MetadataService.retrieveResponse_element(); 317 | new MetadataService.ArticleTypeTemplate(); 318 | new MetadataService.ReportGrouping(); 319 | new MetadataService.PermissionSetFieldPermissions(); 320 | new MetadataService.AnalyticSnapshotMapping(); 321 | new MetadataService.SharingRecalculation(); 322 | new MetadataService.ProfileLoginIpRange(); 323 | new MetadataService.WebLinkTranslation(); 324 | new MetadataService.ObjectRelationship(); 325 | new MetadataService.ListPlacement(); 326 | new MetadataService.SiteRedirectMapping(); 327 | new MetadataService.WorkflowFieldUpdate(); 328 | new MetadataService.LetterheadLine(); 329 | new MetadataService.CustomTab(); 330 | new MetadataService.FlowChoiceUserInput(); 331 | new MetadataService.Letterhead(); 332 | new MetadataService.ReportTypeColumnTranslation(); 333 | new MetadataService.CustomPageWebLinkTranslation(); 334 | new MetadataService.DocumentFolder(); 335 | new MetadataService.FlowConstant(); 336 | new MetadataService.ProfileRecordTypeVisibility(); 337 | new MetadataService.PackageVersion(); 338 | new MetadataService.CustomLabelTranslation(); 339 | new MetadataService.ReportChart(); 340 | new MetadataService.checkRetrieveStatusResponse_element(); 341 | new MetadataService.ProfileFieldLevelSecurity(); 342 | new MetadataService.SharingReason(); 343 | new MetadataService.RunTestsResult(); 344 | new MetadataService.PermissionSetUserPermission(); 345 | new MetadataService.MiniLayout(); 346 | new MetadataService.FlowVariable(); 347 | new MetadataService.ProfileLoginHours(); 348 | new MetadataService.DashboardFilter(); 349 | new MetadataService.CodeLocation(); 350 | new MetadataService.ReportBucketFieldSourceValue(); 351 | new MetadataService.FieldSetItem(); 352 | new MetadataService.ReportFilterItem(); 353 | new MetadataService.FlowDynamicChoiceSet(); 354 | new MetadataService.CustomDataTypeComponent(); 355 | new MetadataService.CustomObjectTranslation(); 356 | new MetadataService.CustomApplication(); 357 | new MetadataService.ReportAggregate(); 358 | new MetadataService.ApexClass(); 359 | new MetadataService.DebuggingInfo_element(); 360 | new MetadataService.Package_x(); 361 | new MetadataService.SessionSettings(); 362 | new MetadataService.Document(); 363 | new MetadataService.Folder(); 364 | new MetadataService.DeployResult(); 365 | new MetadataService.LayoutItem(); 366 | new MetadataService.ProfileApexPageAccess(); 367 | new MetadataService.SharingReasonTranslation(); 368 | new MetadataService.checkDeployStatusResponse_element(); 369 | new MetadataService.ReportColorRange(); 370 | new MetadataService.SearchLayouts(); 371 | new MetadataService.LetterheadHeaderFooter(); 372 | new MetadataService.HomePageComponent(); 373 | new MetadataService.MobileSettings(); 374 | new MetadataService.EscalationRules(); 375 | new MetadataService.KnowledgeAnswerSettings(); 376 | new MetadataService.ExternalDataSource(); 377 | new MetadataService.EntitlementProcess(); 378 | new MetadataService.IdeasSettings(); 379 | new MetadataService.Country(); 380 | new MetadataService.ReputationLevels(); 381 | new MetadataService.KnowledgeSitesSettings(); 382 | new MetadataService.AddressSettings(); 383 | new MetadataService.ProfileExternalDataSourceAccess(); 384 | new MetadataService.CallCenterItem(); 385 | new MetadataService.CallCenter(); 386 | new MetadataService.PermissionSetExternalDataSourceAccess(); 387 | new MetadataService.PermissionSetTabSetting(); 388 | new MetadataService.AuthProvider(); 389 | new MetadataService.EmailToCaseSettings(); 390 | new MetadataService.EscalationAction(); 391 | new MetadataService.State(); 392 | new MetadataService.AssignmentRule(); 393 | new MetadataService.AutoResponseRule(); 394 | new MetadataService.CaseSettings(); 395 | new MetadataService.ChatterAnswersSettings(); 396 | new MetadataService.CountriesAndStates(); 397 | new MetadataService.SFDCMobileSettings(); 398 | new MetadataService.EntitlementProcessMilestoneItem(); 399 | new MetadataService.TouchMobileSettings(); 400 | new MetadataService.AssignmentRules(); 401 | new MetadataService.ContractSettings(); 402 | new MetadataService.KnowledgeCaseSettings(); 403 | new MetadataService.ChatterAnswersReputationLevel(); 404 | new MetadataService.KnowledgeSettings(); 405 | new MetadataService.Community(); 406 | new MetadataService.AutoResponseRules(); 407 | new MetadataService.EmailToCaseRoutingAddress(); 408 | new MetadataService.RuleEntry(); 409 | new MetadataService.EntitlementSettings(); 410 | new MetadataService.ApexPage(); 411 | new MetadataService.WorkflowSend(); 412 | new MetadataService.ChatterMobileSettings(); 413 | new MetadataService.CallCenterSection(); 414 | new MetadataService.EntitlementProcessMilestoneTimeTrigger(); 415 | new MetadataService.StaticResource(); 416 | new MetadataService.MilestoneType(); 417 | new MetadataService.FiscalYearSettings(); 418 | new MetadataService.CompanySettings(); 419 | new MetadataService.WebToCaseSettings(); 420 | new MetadataService.EscalationRule(); 421 | new MetadataService.DashboardMobileSettings(); 422 | new MetadataService.FieldOverride(); 423 | new MetadataService.QuotasSettings(); 424 | new MetadataService.Skill(); 425 | new MetadataService.AgentConfigProfileAssignments(); 426 | new MetadataService.LiveAgentSettings(); 427 | new MetadataService.SkillAssignments(); 428 | new MetadataService.ActivitiesSettings(); 429 | new MetadataService.LiveAgentConfig(); 430 | new MetadataService.ApprovalPageField(); 431 | new MetadataService.QuickActionList(); 432 | new MetadataService.LiveChatButtonDeployments(); 433 | new MetadataService.InstalledPackage(); 434 | new MetadataService.PushNotification(); 435 | new MetadataService.LiveChatAgentConfig(); 436 | new MetadataService.AdjustmentsSettings(); 437 | new MetadataService.ForecastingSettings(); 438 | new MetadataService.QuickActionListItem(); 439 | //new MetadataService.Branding(); 440 | new MetadataService.QuickActionLayoutItem(); 441 | new MetadataService.OpportunityListFieldsSelectedSettings(); 442 | new MetadataService.ApprovalStepRejectBehavior(); 443 | new MetadataService.FolderShare(); 444 | new MetadataService.ApprovalEntryCriteria(); 445 | new MetadataService.ProductSettings(); 446 | new MetadataService.OpportunitySettings(); 447 | new MetadataService.LiveChatDeployment(); 448 | new MetadataService.QuickActionLayoutColumn(); 449 | new MetadataService.GlobalQuickActionTranslation(); 450 | new MetadataService.ApprovalStepApprover(); 451 | new MetadataService.QuoteSettings(); 452 | new MetadataService.LiveChatButton(); 453 | new MetadataService.Network(); 454 | new MetadataService.LiveChatDeploymentDomainWhitelist(); 455 | new MetadataService.KnowledgeLanguageSettings(); 456 | new MetadataService.Approver(); 457 | new MetadataService.SamlSsoConfig(); 458 | new MetadataService.ApprovalSubmitter(); 459 | new MetadataService.KeyboardShortcuts(); 460 | new MetadataService.ApprovalStep(); 461 | new MetadataService.AgentConfigAssignments(); 462 | new MetadataService.QuickAction(); 463 | new MetadataService.DefaultShortcut(); 464 | new MetadataService.ApprovalAction(); 465 | new MetadataService.KnowledgeLanguage(); 466 | new MetadataService.LiveChatButtonSkills(); 467 | new MetadataService.SkillUserAssignments(); 468 | new MetadataService.NextAutomatedApprover(); 469 | new MetadataService.ApprovalProcess(); 470 | new MetadataService.QuickActionLayout(); 471 | //new MetadataService.PushNotifications(); 472 | new MetadataService.ForecastRangeSettings(); 473 | new MetadataService.IdeaReputationLevel(); 474 | new MetadataService.NetworkTabSet(); 475 | new MetadataService.SkillProfileAssignments(); 476 | new MetadataService.CustomShortcut(); 477 | //new MetadataService.PagesToOpen(); 478 | new MetadataService.AgentConfigUserAssignments(); 479 | new MetadataService.NetworkMemberGroup(); 480 | new MetadataService.FindSimilarOppFilter(); 481 | new MetadataService.QuickActionTranslation(); 482 | new MetadataService.WorkflowFlowActionParameter(); 483 | new MetadataService.ConnectedAppOauthConfig(); 484 | new MetadataService.FlowLoop(); 485 | new MetadataService.renameMetadata_element(); 486 | new MetadataService.ForecastingTypeSettings(); 487 | new MetadataService.PermissionSetApplicationVisibility(); 488 | new MetadataService.FeedLayout(); 489 | new MetadataService.AppMenuItem(); 490 | new MetadataService.deleteMetadataResponse_element(); 491 | new MetadataService.ConnectedAppAttribute(); 492 | new MetadataService.ReportChartComponentLayoutItem(); 493 | new MetadataService.AppMenu(); 494 | new MetadataService.ConnectedAppIpRange(); 495 | new MetadataService.Error(); 496 | new MetadataService.ComponentInstanceProperty(); 497 | new MetadataService.BusinessHoursEntry(); 498 | new MetadataService.RelatedContent(); 499 | new MetadataService.SupervisorAgentConfigSkills(); 500 | new MetadataService.ComponentInstance(); 501 | new MetadataService.SidebarComponent(); 502 | new MetadataService.Holiday(); 503 | new MetadataService.SaveResult(); 504 | new MetadataService.readMetadataResponse_element(); 505 | new MetadataService.FlexiPageRegion(); 506 | new MetadataService.deleteMetadata_element(); 507 | new MetadataService.ConnectedAppMobileDetailConfig(); 508 | new MetadataService.AccountSettings(); 509 | new MetadataService.PermissionSetRecordTypeVisibility(); 510 | new MetadataService.OrderSettings(); 511 | new MetadataService.ProfileUserPermission(); 512 | new MetadataService.LookupFilterTranslation(); 513 | new MetadataService.WorkflowFlowAction(); 514 | new MetadataService.ConnectedApp(); 515 | new MetadataService.SiteDotCom(); 516 | new MetadataService.createMetadataResponse_element(); 517 | new MetadataService.updateMetadata_element(); 518 | new MetadataService.LookupFilter(); 519 | new MetadataService.updateMetadataResponse_element(); 520 | new MetadataService.FlexiPage(); 521 | new MetadataService.ConnectedAppSamlConfig(); 522 | new MetadataService.createMetadata_element(); 523 | new MetadataService.FeedLayoutComponent(); 524 | new MetadataService.PostTemplate(); 525 | new MetadataService.RelatedContentItem(); 526 | new MetadataService.readMetadata_element(); 527 | new MetadataService.ReadWorkflowRuleResult(); 528 | new MetadataService.readWorkflowRuleResponse_element(); 529 | new MetadataService.ReadSamlSsoConfigResult(); 530 | new MetadataService.readSamlSsoConfigResponse_element(); 531 | new MetadataService.ReadCustomLabelResult(); 532 | new MetadataService.readCustomLabelResponse_element(); 533 | new MetadataService.ReadBusinessHoursEntryResult(); 534 | new MetadataService.readBusinessHoursEntryResponse_element(); 535 | new MetadataService.ReadMobileSettingsResult(); 536 | new MetadataService.readMobileSettingsResponse_element(); 537 | new MetadataService.ReadChatterAnswersSettingsResult(); 538 | new MetadataService.readChatterAnswersSettingsResponse_element(); 539 | new MetadataService.ReadSharingRulesResult(); 540 | new MetadataService.readSharingRulesResponse_element(); 541 | new MetadataService.ReadPortalResult(); 542 | new MetadataService.readPortalResponse_element(); 543 | new MetadataService.ReadSkillResult(); 544 | new MetadataService.readSkillResponse_element(); 545 | new MetadataService.ReadEscalationRulesResult(); 546 | new MetadataService.readEscalationRulesResponse_element(); 547 | new MetadataService.ReadCustomDataTypeResult(); 548 | new MetadataService.readCustomDataTypeResponse_element(); 549 | new MetadataService.ReadExternalDataSourceResult(); 550 | new MetadataService.readExternalDataSourceResponse_element(); 551 | new MetadataService.ReadEntitlementProcessResult(); 552 | new MetadataService.readEntitlementProcessResponse_element(); 553 | new MetadataService.ReadRecordTypeResult(); 554 | new MetadataService.readRecordTypeResponse_element(); 555 | new MetadataService.ReadScontrolResult(); 556 | new MetadataService.readScontrolResponse_element(); 557 | new MetadataService.ReadDataCategoryGroupResult(); 558 | new MetadataService.readDataCategoryGroupResponse_element(); 559 | new MetadataService.ReadValidationRuleResult(); 560 | new MetadataService.readValidationRuleResponse_element(); 561 | new MetadataService.ReadProfileResult(); 562 | new MetadataService.readProfileResponse_element(); 563 | new MetadataService.ReadIdeasSettingsResult(); 564 | new MetadataService.readIdeasSettingsResponse_element(); 565 | new MetadataService.ReadConnectedAppResult(); 566 | new MetadataService.readConnectedAppResponse_element(); 567 | new MetadataService.ReadApexPageResult(); 568 | new MetadataService.readApexPageResponse_element(); 569 | new MetadataService.ReadProductSettingsResult(); 570 | new MetadataService.readProductSettingsResponse_element(); 571 | new MetadataService.ReadLiveAgentSettingsResult(); 572 | new MetadataService.readLiveAgentSettingsResponse_element(); 573 | new MetadataService.ReadOpportunitySettingsResult(); 574 | new MetadataService.readOpportunitySettingsResponse_element(); 575 | new MetadataService.ReadLiveChatDeploymentResult(); 576 | new MetadataService.readLiveChatDeploymentResponse_element(); 577 | new MetadataService.ReadActivitiesSettingsResult(); 578 | new MetadataService.readActivitiesSettingsResponse_element(); 579 | new MetadataService.ReadLayoutResult(); 580 | new MetadataService.readLayoutResponse_element(); 581 | new MetadataService.ReadWebLinkResult(); 582 | new MetadataService.readWebLinkResponse_element(); 583 | new MetadataService.ReadSiteDotComResult(); 584 | new MetadataService.readSiteDotComResponse_element(); 585 | new MetadataService.ReadCompanySettingsResult(); 586 | new MetadataService.readCompanySettingsResponse_element(); 587 | new MetadataService.ReadHomePageLayoutResult(); 588 | new MetadataService.readHomePageLayoutResponse_element(); 589 | new MetadataService.ReadDashboardResult(); 590 | new MetadataService.readDashboardResponse_element(); 591 | new MetadataService.ReadAssignmentRulesResult(); 592 | new MetadataService.readAssignmentRulesResponse_element(); 593 | new MetadataService.ReadAnalyticSnapshotResult(); 594 | new MetadataService.readAnalyticSnapshotResponse_element(); 595 | new MetadataService.ReadEscalationRuleResult(); 596 | new MetadataService.readEscalationRuleResponse_element(); 597 | new MetadataService.ReadCustomSiteResult(); 598 | new MetadataService.readCustomSiteResponse_element(); 599 | new MetadataService.ReadGroupResult(); 600 | new MetadataService.readGroupResponse_element(); 601 | new MetadataService.ReadReportTypeResult(); 602 | new MetadataService.readReportTypeResponse_element(); 603 | new MetadataService.ReadQuickActionResult(); 604 | new MetadataService.readQuickActionResponse_element(); 605 | new MetadataService.ReadCustomPageWebLinkResult(); 606 | new MetadataService.readCustomPageWebLinkResponse_element(); 607 | new MetadataService.ReadApexComponentResult(); 608 | new MetadataService.readApexComponentResponse_element(); 609 | new MetadataService.ReadEntitlementTemplateResult(); 610 | new MetadataService.readEntitlementTemplateResponse_element(); 611 | new MetadataService.ReadFlexiPageResult(); 612 | new MetadataService.readFlexiPageResponse_element(); 613 | new MetadataService.ReadWorkflowResult(); 614 | new MetadataService.readWorkflowResponse_element(); 615 | new MetadataService.ReadWorkflowActionResult(); 616 | new MetadataService.readWorkflowActionResponse_element(); 617 | new MetadataService.ReadAddressSettingsResult(); 618 | new MetadataService.readAddressSettingsResponse_element(); 619 | new MetadataService.ReadContractSettingsResult(); 620 | new MetadataService.readContractSettingsResponse_element(); 621 | new MetadataService.ReadCustomObjectResult(); 622 | new MetadataService.readCustomObjectResponse_element(); 623 | new MetadataService.ReadTranslationsResult(); 624 | new MetadataService.readTranslationsResponse_element(); 625 | new MetadataService.ReadRoleOrTerritoryResult(); 626 | new MetadataService.readRoleOrTerritoryResponse_element(); 627 | new MetadataService.ReadApexTriggerResult(); 628 | new MetadataService.readApexTriggerResponse_element(); 629 | new MetadataService.ReadCustomLabelsResult(); 630 | new MetadataService.readCustomLabelsResponse_element(); 631 | new MetadataService.ReadSecuritySettingsResult(); 632 | new MetadataService.readSecuritySettingsResponse_element(); 633 | new MetadataService.ReadCallCenterResult(); 634 | new MetadataService.readCallCenterResponse_element(); 635 | new MetadataService.ReadPicklistValueResult(); 636 | new MetadataService.readPicklistValueResponse_element(); 637 | new MetadataService.ReadRemoteSiteSettingResult(); 638 | new MetadataService.readRemoteSiteSettingResponse_element(); 639 | new MetadataService.ReadQuoteSettingsResult(); 640 | new MetadataService.readQuoteSettingsResponse_element(); 641 | new MetadataService.ReadSynonymDictionaryResult(); 642 | new MetadataService.readSynonymDictionaryResponse_element(); 643 | new MetadataService.ReadPostTemplateResult(); 644 | new MetadataService.readPostTemplateResponse_element(); 645 | new MetadataService.ReadCustomTabResult(); 646 | new MetadataService.readCustomTabResponse_element(); 647 | new MetadataService.ReadLetterheadResult(); 648 | new MetadataService.readLetterheadResponse_element(); 649 | new MetadataService.ReadInstalledPackageResult(); 650 | new MetadataService.readInstalledPackageResponse_element(); 651 | new MetadataService.ReadQueueResult(); 652 | new MetadataService.readQueueResponse_element(); 653 | new MetadataService.ReadAuthProviderResult(); 654 | new MetadataService.readAuthProviderResponse_element(); 655 | new MetadataService.ReadEntitlementSettingsResult(); 656 | new MetadataService.readEntitlementSettingsResponse_element(); 657 | new MetadataService.ReadCustomFieldResult(); 658 | new MetadataService.readCustomFieldResponse_element(); 659 | new MetadataService.ReadStaticResourceResult(); 660 | new MetadataService.readStaticResourceResponse_element(); 661 | new MetadataService.ReadEmailTemplateResult(); 662 | new MetadataService.readEmailTemplateResponse_element(); 663 | new MetadataService.ReadSharingReasonResult(); 664 | new MetadataService.readSharingReasonResponse_element(); 665 | new MetadataService.ReadLiveChatButtonResult(); 666 | new MetadataService.readLiveChatButtonResponse_element(); 667 | new MetadataService.ReadNetworkResult(); 668 | new MetadataService.readNetworkResponse_element(); 669 | new MetadataService.ReadApprovalProcessResult(); 670 | new MetadataService.readApprovalProcessResponse_element(); 671 | new MetadataService.ReadMilestoneTypeResult(); 672 | new MetadataService.readMilestoneTypeResponse_element(); 673 | new MetadataService.ReadAssignmentRuleResult(); 674 | new MetadataService.readAssignmentRuleResponse_element(); 675 | new MetadataService.ReadCompactLayoutResult(); 676 | new MetadataService.readCompactLayoutResponse_element(); 677 | new MetadataService.ReadLiveChatAgentConfigResult(); 678 | new MetadataService.readLiveChatAgentConfigResponse_element(); 679 | new MetadataService.ReadAccountSettingsResult(); 680 | new MetadataService.readAccountSettingsResponse_element(); 681 | new MetadataService.ReadBusinessProcessResult(); 682 | new MetadataService.readBusinessProcessResponse_element(); 683 | new MetadataService.ReadFlowResult(); 684 | new MetadataService.readFlowResponse_element(); 685 | new MetadataService.ReadAutoResponseRuleResult(); 686 | new MetadataService.readAutoResponseRuleResponse_element(); 687 | new MetadataService.ReadPermissionSetResult(); 688 | new MetadataService.readPermissionSetResponse_element(); 689 | new MetadataService.ReadBusinessHoursSettingsResult(); 690 | new MetadataService.readBusinessHoursSettingsResponse_element(); 691 | new MetadataService.ReadForecastingSettingsResult(); 692 | new MetadataService.readForecastingSettingsResponse_element(); 693 | new MetadataService.ReadReportResult(); 694 | new MetadataService.readReportResponse_element(); 695 | new MetadataService.ReadAppMenuResult(); 696 | new MetadataService.readAppMenuResponse_element(); 697 | new MetadataService.ReadListViewResult(); 698 | new MetadataService.readListViewResponse_element(); 699 | new MetadataService.ReadOrderSettingsResult(); 700 | new MetadataService.readOrderSettingsResponse_element(); 701 | new MetadataService.ReadCustomObjectTranslationResult(); 702 | new MetadataService.readCustomObjectTranslationResponse_element(); 703 | new MetadataService.ReadCustomApplicationResult(); 704 | new MetadataService.readCustomApplicationResponse_element(); 705 | new MetadataService.ReadKnowledgeSettingsResult(); 706 | new MetadataService.readKnowledgeSettingsResponse_element(); 707 | new MetadataService.ReadCaseSettingsResult(); 708 | new MetadataService.readCaseSettingsResponse_element(); 709 | new MetadataService.ReadApexClassResult(); 710 | new MetadataService.readApexClassResponse_element(); 711 | new MetadataService.ReadPackageResult(); 712 | new MetadataService.readPackageResponse_element(); 713 | new MetadataService.ReadCommunityResult(); 714 | new MetadataService.readCommunityResponse_element(); 715 | new MetadataService.ReadDocumentResult(); 716 | new MetadataService.readDocumentResponse_element(); 717 | new MetadataService.ReadAutoResponseRulesResult(); 718 | new MetadataService.readAutoResponseRulesResponse_element(); 719 | new MetadataService.ReadFolderResult(); 720 | new MetadataService.readFolderResponse_element(); 721 | new MetadataService.ReadCustomApplicationComponentResult(); 722 | new MetadataService.readCustomApplicationComponentResponse_element(); 723 | new MetadataService.ReadFieldSetResult(); 724 | new MetadataService.readFieldSetResponse_element(); 725 | new MetadataService.ReadSharingSetResult(); 726 | new MetadataService.readSharingSetResponse_element(); 727 | new MetadataService.ReadHomePageComponentResult(); 728 | new MetadataService.readHomePageComponentResponse_element(); 729 | new MetadataService.ReadResult(); 730 | new MetadataService.BusinessHoursSettings(); 731 | new MetadataService.FeedLayoutFilter(); 732 | new MetadataService.ReportHistoricalSelector(); 733 | new MetadataService.ConnectedAppCanvasConfig(); 734 | new MetadataService.DeployDetails(); 735 | new MetadataService.ReportDataCategoryFilter(); 736 | new MetadataService.SynonymGroup(); 737 | new MetadataService.renameMetadataResponse_element(); 738 | new MetadataService.cancelDeploy_element(); 739 | new MetadataService.CancelDeployResult(); 740 | new MetadataService.SynonymDictionary(); 741 | new MetadataService.cancelDeployResponse_element(); 742 | new MetadataService.CompactLayout(); 743 | new MetadataService.AccessMapping(); 744 | new MetadataService.Container(); 745 | new MetadataService.DeleteResult(); 746 | new MetadataService.SharingSet(); 747 | new MetadataService.ReputationPointsRule(); 748 | new MetadataService.FlowActionCallInputParameter(); 749 | new MetadataService.CustomMetadata(); 750 | new MetadataService.VisualizationPlugin(); 751 | new MetadataService.RelatedList(); 752 | new MetadataService.FlowActionCallOutputParameter(); 753 | new MetadataService.FlowActionCall(); 754 | new MetadataService.CustomPermission(); 755 | new MetadataService.ReputationLevelDefinitions(); 756 | new MetadataService.PermissionSetCustomPermissions(); 757 | new MetadataService.upsertMetadata_element(); 758 | new MetadataService.ProfileCustomPermissions(); 759 | new MetadataService.AgentConfigButtons(); 760 | new MetadataService.AgentConfigSkills(); 761 | new MetadataService.upsertMetadataResponse_element(); 762 | new MetadataService.ReputationLevel(); 763 | new MetadataService.ReadWorkflowAlertResult(); 764 | new MetadataService.readWorkflowAlertResponse_element(); 765 | new MetadataService.ReadCustomPermissionResult(); 766 | new MetadataService.readCustomPermissionResponse_element(); 767 | new MetadataService.ReadSiteDotComResult(); 768 | new MetadataService.ReadEmailFolderResult(); 769 | new MetadataService.readEmailFolderResponse_element(); 770 | new MetadataService.ReadCustomMetadataResult(); 771 | new MetadataService.readCustomMetadataResponse_element(); 772 | new MetadataService.ReadAnalyticSnapshotResult(); 773 | new MetadataService.readAnalyticSnapshotResponse_element(); 774 | new MetadataService.ReadVisualizationPluginResult(); 775 | new MetadataService.readVisualizationPluginResponse_element(); 776 | new MetadataService.ReadEscalationRuleResult(); 777 | new MetadataService.ReadMarketingActionSettingsResult(); 778 | new MetadataService.readMarketingActionSettingsResponse_element(); 779 | new MetadataService.ReadWorkflowKnowledgePublishResult(); 780 | new MetadataService.readWorkflowKnowledgePublishResponse_element(); 781 | new MetadataService.ReadDashboardFolderResult(); 782 | new MetadataService.readDashboardFolderResponse_element(); 783 | new MetadataService.ReadWorkflowSendResult(); 784 | new MetadataService.readWorkflowSendResponse_element(); 785 | new MetadataService.ReadWorkflowOutboundMessageResult(); 786 | new MetadataService.readWorkflowOutboundMessageResponse_element(); 787 | new MetadataService.ReadWorkflowFieldUpdateResult(); 788 | new MetadataService.readWorkflowFieldUpdateResponse_element(); 789 | new MetadataService.ReadDocumentFolderResult(); 790 | new MetadataService.readDocumentFolderResponse_element(); 791 | new MetadataService.ReadWorkflowTaskResult(); 792 | new MetadataService.readWorkflowTaskResponse_element(); 793 | new MetadataService.ReadNameSettingsResult(); 794 | new MetadataService.readNameSettingsResponse_element(); 795 | new MetadataService.ReadReportFolderResult(); 796 | new MetadataService.readReportFolderResponse_element(); 797 | new MetadataService.ReadCustomApplicationComponentResult(); 798 | new MetadataService.NameSettings(); 799 | new MetadataService.ReputationPointsRules(); 800 | new MetadataService.FlowMetadataValue(); 801 | new MetadataService.VisualizationResource(); 802 | new MetadataService.MarketingActionSettings(); 803 | new MetadataService.VisualizationType(); 804 | new MetadataService.CustomMetadataValue(); 805 | new MetadataService.HistoryRetentionPolicy(); 806 | new MetadataService.UpsertResult(); 807 | new MetaDataService.Territory2RuleAssociation(); 808 | new MetadataService.ManagedTopics(); 809 | new MetaDataService.XOrgHub(); 810 | new MetaDataService.FlowWaitEventInputParameter(); 811 | new MetadataService.ManagedTopic(); 812 | new MetadataService.Territory2RuleItem(); 813 | new MetadataService.DataPipeline(); 814 | new MetadataService.UiPlugin(); 815 | new MetadataService.Territory2Rule(); 816 | new MetaDataService.XOrgHubSharedObject(); 817 | new MetadataService.Territory2Type(); 818 | new MetadataService.CorsWhitelistOrigin(); 819 | new MetadataService.StandardFieldTranslation(); 820 | new MetadataService.Territory2Model(); 821 | new MetadataService.PersonListSettings(); 822 | new MetadataService.ChannelLayoutItem(); 823 | new MetadataService.FlowWait(); 824 | new MetadataService.Territory2Settings(); 825 | new MetadataService.FieldValue(); 826 | new MetadataService.ChannelLayout(); 827 | new MetadataService.ReadXOrgHubResult(); 828 | new MetadataService.readXOrgHubResponse_element(); 829 | new MetadataService.ReadAuraDefinitionBundleResult(); 830 | new MetadataService.readAuraDefinitionBundleResponse_element(); 831 | new MetadataService.ReadTerritory2SettingsResult(); 832 | new MetadataService.readTerritory2SettingsResponse_element(); 833 | new MetadataService.ReadTerritory2TypeResult(); 834 | new MetadataService.readTerritory2TypeResponse_element(); 835 | new MetadataService.ReadQuoteSettingsResult(); 836 | new MetadataService.readQuoteSettingsResponse_element(); 837 | new MetadataService.ReadCorsWhitelistOriginResult(); 838 | new MetadataService.readCorsWhitelistOriginResponse_element(); 839 | new MetadataService.ReadManagedTopicsResult(); 840 | new MetadataService.readManagedTopicsResponse_element(); 841 | new MetadataService.ReadTerritory2Result(); 842 | new MetadataService.readTerritory2Response_element(); 843 | new MetadataService.ReadCommunityResult(); 844 | new MetadataService.readCommunityResponse_element(); 845 | new MetadataService.ReadDocumentResult(); 846 | new MetadataService.readDocumentResponse_element(); 847 | new MetadataService.ReadTerritory2ModelResult(); 848 | new MetadataService.readTerritory2ModelResponse_element(); 849 | new MetadataService.FlowWaitEventOutputParameter(); 850 | new MetadataService.FlowWaitEvent(); 851 | new MetadataService.CustomPermissionDependencyRequired(); 852 | new MetadataService.ReputationBranding(); 853 | new MetadataService.AuraDefinitionBundle(); 854 | new MetadataService.FeedItemSettings(); 855 | new MetadataService.FlowBaseElement(); 856 | new MetadataService.Territory2(); 857 | new MetaDataService.deployRecentValidationResponse_element(); 858 | new MetaDataService.SharingCriteriaRule(); 859 | new MetaDataService.ActionLinkGroupTemplate(); 860 | new MetaDataService.MatchingRule(); 861 | new MetaDataService.describeValueType_element(); 862 | new MetaDataService.LicensedCustomPermissions(); 863 | new MetaDataService.MatchingRuleItem(); 864 | new MetaDataService.MarketingResourceType(); 865 | new MetaDataService.SharingBaseRule(); 866 | new MetaDataService.MatchingRules(); 867 | new MetaDataService.deployRecentValidation_element(); 868 | new MetaDataService.ActionLinkTemplate(); 869 | new MetaDataService.SharingTerritoryRule(); 870 | new MetaDataService.PersonalJourneySettings(); 871 | new MetaDataService.LicenseDefinition(); 872 | new MetaDataService.AccountSharingRuleSettings(); 873 | new MetaDataService.NamedCredential(); 874 | new MetaDataService.DescribeValueTypeResult(); 875 | new MetaDataService.ReadSharingTerritoryRuleResult(); 876 | new MetaDataService.readSharingTerritoryRuleResponse_element(); 877 | new MetadataService.ReadPersonalJourneySettingsResult(); 878 | new MetaDataService.readPersonalJourneySettingsResponse_element(); 879 | new MetaDataService.ReadMarketingResourceTypeResult(); 880 | new MetaDataService.readMarketingResourceTypeResponse_element(); 881 | new MetaDataService.ReadSharingCriteriaRuleResult(); 882 | new MetaDataService.readSharingCriteriaRuleResponse_element(); 883 | new MetaDataService.ReadLicenseDefinitionResult(); 884 | new MetaDataService.readLicenseDefinitionResponse_element(); 885 | new MetaDataService.ReadActionLinkGroupTemplateResult(); 886 | new MetaDataService.readActionLinkGroupTemplateResponse_element(); 887 | new MetaDataService.ReadNamedCredentialResult(); 888 | new MetaDataService.readNamedCredentialResponse_element(); 889 | new MetaDataService.ReadSharingOwnerRuleResult(); 890 | new MetaDataService.readSharingOwnerRuleResponse_element(); 891 | new MetaDataService.ReadSharingBaseRuleResult(); 892 | new MetaDataService.readSharingBaseRuleResponse_element(); 893 | new MetaDataService.ReadMatchingRulesResult(); 894 | new MetaDataService.readMatchingRulesResponse_element(); 895 | new MetaDataService.ReadMatchingRuleResult(); 896 | new MetaDataService.readMatchingRuleResponse_element(); 897 | new MetaDataService.SharingOwnerRule(); 898 | new MetaDataService.PicklistEntry(); 899 | new MetaDataService.ValueTypeField(); 900 | new MetaDataService.DashboardGridComponent(); 901 | new MetaDataService.AllOrNoneHeader_element(); 902 | new MetaDataService.WeightedSourceCategory(); 903 | new MetaDataService.Territory2SettingsOpportunityFilter(); 904 | new MetaDataService.PathAssistantStep(); 905 | new MetaDataService.DashboardGridLayout(); 906 | new MetaDataService.PlatformActionList(); 907 | new MetaDataService.FeedFilterCriterion(); 908 | new MetaDataService.PathAssistant(); 909 | new MetaDataService.PlatformCachePartition(); 910 | new MetaDataService.FlowDefinition(); 911 | new MetaDataService.WaveTemplateBundle(); 912 | new MetaDataService.TransactionSecurityAction(); 913 | new MetaDataService.PlatformActionListItem(); 914 | new MetaDataService.PlatformCachePartitionType(); 915 | new MetaDataService.TransactionSecurityPolicy(); 916 | new MetaDataService.KnowledgeCommunitiesSettings(); 917 | new MetaDataService.PathAssistantSettings(); 918 | new MetaDataService.AnalyticsCloudComponentLayoutItem(); 919 | new MetaDataService.CustomFeedFilter(); 920 | new MetaDataService.LeadConvertSettings(); 921 | new MetaDataService.ForecastingCategoryMapping(); 922 | new MetaDataService.LiveChatSensitiveDataRule(); 923 | new MetaDataService.TransactionSecurityNotification(); 924 | new MetadataService.DelegateGroup(); 925 | new MetadataService.EventDelivery(); 926 | new MetadataService.EventSubscription(); 927 | new MetadataService.EventType(); 928 | new MetadataService.Certificate(); 929 | new MetadataService.ModerationRule(); 930 | new MetadataService.WaveApplication(); 931 | new MetadataService.WaveDataset(); 932 | new MetadataService.WaveDashboard(); 933 | new MetaDataService.WaveDataflow(); 934 | new MetaDataService.WaveLens(); 935 | new MetaDataService.OrgPreferenceSettings(); 936 | new MetaDataService.SearchSettings(); 937 | new MetadataService.GlobalPicklistValue(); 938 | new MetadataService.PicklistValue(); 939 | new MetadataService.KeywordList(); 940 | new MetadataService.EmbeddedServiceLiveAgent(); 941 | new MetadataService.GlobalValueSet(); 942 | new MetadataService.OrganizationSettingsDetail(); 943 | new MetadataService.DuplicateRuleFilterItem(); 944 | new MetadataService.ContentAsset(); 945 | new MetadataService.EmbeddedServiceConfig(); 946 | new MetadataService.DuplicateRule(); 947 | new MetadataService.ValueSetValuesDefinition(); 948 | new MetadataService.ObjectSearchSetting(); 949 | new MetadataService.Keyword(); 950 | new MetadataService.OpportunityListFieldsLabelMapping(); 951 | new MetadataService.NavigationMenuItem(); 952 | new MetadataService.DuplicateRuleFilter(); 953 | new MetadataService.SearchSettingsByObject(); 954 | new MetadataService.CustomExperienceBranding(); 955 | new MetadataService.EventTypeParameter(); 956 | new MetadataService.DuplicateRuleMatchRule(); 957 | new MetadataService.FlowScreenRuleAction(); 958 | new MetadataService.KnowledgeCaseFieldsSettings(); 959 | new MetadataService.ObjectMappingField(); 960 | new MetadataService.ValueSet(); 961 | new MetadataService.ProfileActionOverride(); 962 | new MetadataService.ContentAssetRelationships(); 963 | new MetadataService.ContentAssetVersions(); 964 | new MetadataService.ExternalServiceRegistration(); 965 | new MetadataService.CustomExperience(); 966 | new MetadataService.KnowledgeCaseField(); 967 | new MetadataService.FieldMappingRow(); 968 | new MetadataService.EventParameterMap(); 969 | new MetadataService.ContentAssetVersion(); 970 | new MetadataService.AppBrand(); 971 | new MetadataService.ModeratedEntityField(); 972 | new MetadataService.ObjectMapping(); 973 | new MetadataService.TabLimitConfig(); 974 | new MetadataService.FieldMapping(); 975 | new MetadataService.ValueTranslation(); 976 | new MetadataService.StandardValueSet(); 977 | new MetadataService.FlowScreenRule(); 978 | new MetadataService.NavigationLinkSet(); 979 | new MetadataService.StandardValueSetTranslation(); 980 | new MetadataService.OpportunityListFieldsUnselectedSettings(); 981 | new MetadataService.GlobalValueSetTranslation(); 982 | new MetadataService.StandardValue(); 983 | new MetadataService.ContentAssetLink(); 984 | new MetadataService.ApexTestSuite(); 985 | new MetadataService.QuickActionSendEmailOptions(); 986 | new MetadataService.ValueSettings(); 987 | new MetadataService.FieldMappingField(); 988 | new MetadataService.CustomExperienceTabSet(); 989 | new MetadataService.KnowledgeSuggestedArticlesSettings(); 990 | Test.stopTest(); 991 | } 992 | 993 | @IsTest 994 | private static void elfMissingGetRecordsTest() { // elf patch 995 | Test.startTest(); 996 | new MetadataService.ReadFlowResult().getRecords(); 997 | new MetadataService.ReadWorkflowResult().getRecords(); 998 | new MetadataService.ReadWorkflowRuleResult().getRecords(); 999 | new MetadataService.ReadAssignmentRulesResult().getRecords(); 1000 | new MetadataService.ReadAssignmentRuleResult().getRecords(); 1001 | new MetadataService.ReadAutoResponseRulesResult().getRecords(); 1002 | new MetadataService.ReadAutoResponseRuleResult().getRecords(); 1003 | new MetadataService.ReadEscalationRulesResult().getRecords(); 1004 | new MetadataService.ReadEscalationRuleResult().getRecords(); 1005 | new MetadataService.ReadPostTemplateResult().getRecords(); 1006 | new MetadataService.ReadApprovalProcessResult().getRecords(); 1007 | new MetadataService.ReadHomePageComponentResult().getRecords(); 1008 | new MetadataService.ReadHomePageLayoutResult().getRecords(); 1009 | new MetadataService.ReadCustomObjectTranslationResult().getRecords(); 1010 | new MetadataService.ReadTranslationsResult().getRecords(); 1011 | new MetadataService.ReadProfileResult().getRecords(); 1012 | new MetadataService.ReadPermissionSetResult().getRecords(); 1013 | new MetadataService.ReadDataCategoryGroupResult().getRecords(); 1014 | new MetadataService.ReadRemoteSiteSettingResult().getRecords(); 1015 | new MetadataService.ReadPackageResult().getRecords(); 1016 | new MetadataService.ReadAuthProviderResult().getRecords(); 1017 | new MetadataService.ReadKnowledgeSettingsResult().getRecords(); 1018 | new MetadataService.ReadSharingSetResult().getRecords(); 1019 | new MetadataService.ReadSecuritySettingsResult().getRecords(); 1020 | new MetadataService.ReadIdeasSettingsResult().getRecords(); 1021 | new MetadataService.ReadChatterAnswersSettingsResult().getRecords(); 1022 | new MetadataService.ReadCommunityResult().getRecords(); 1023 | new MetadataService.ReadActivitiesSettingsResult().getRecords(); 1024 | new MetadataService.ReadContractSettingsResult().getRecords(); 1025 | new MetadataService.ReadOrderSettingsResult().getRecords(); 1026 | new MetadataService.ReadOpportunitySettingsResult().getRecords(); 1027 | new MetadataService.ReadProductSettingsResult().getRecords(); 1028 | new MetadataService.ReadQuoteSettingsResult().getRecords(); 1029 | new MetadataService.ReadCallCenterResult().getRecords(); 1030 | new MetadataService.ReadEntitlementProcessResult().getRecords(); 1031 | new MetadataService.ReadMilestoneTypeResult().getRecords(); 1032 | new MetadataService.ReadEntitlementTemplateResult().getRecords(); 1033 | new MetadataService.ReadEntitlementSettingsResult().getRecords(); 1034 | new MetadataService.ReadBusinessHoursSettingsResult().getRecords(); 1035 | new MetadataService.ReadBusinessHoursEntryResult().getRecords(); 1036 | new MetadataService.ReadConnectedAppResult().getRecords(); 1037 | new MetadataService.ReadAppMenuResult().getRecords(); 1038 | new MetadataService.ReadMobileSettingsResult().getRecords(); 1039 | new MetadataService.ReadNetworkResult().getRecords(); 1040 | new MetadataService.ReadCompanySettingsResult().getRecords(); 1041 | new MetadataService.ReadForecastingSettingsResult().getRecords(); 1042 | new MetadataService.ReadSamlSsoConfigResult().getRecords(); 1043 | new MetadataService.ReadLiveAgentSettingsResult().getRecords(); 1044 | new MetadataService.ReadSkillResult().getRecords(); 1045 | new MetadataService.ReadLiveChatDeploymentResult().getRecords(); 1046 | new MetadataService.ReadLiveChatButtonResult().getRecords(); 1047 | new MetadataService.ReadLiveChatAgentConfigResult().getRecords(); 1048 | new MetadataService.ReadSynonymDictionaryResult().getRecords(); 1049 | new MetadataService.ReadFolderResult().getRecords(); 1050 | new MetadataService.ReadReportFolderResult().getRecords(); 1051 | new MetadataService.ReadDashboardFolderResult().getRecords(); 1052 | new MetadataService.ReadDocumentFolderResult().getRecords(); 1053 | new MetadataService.ReadEmailFolderResult().getRecords(); 1054 | new MetadataService.ReadRoleOrTerritoryResult().getRecords(); 1055 | new MetadataService.ReadWorkflowActionResult().getRecords(); 1056 | new MetadataService.ReadSiteDotComResult().getRecords(); 1057 | new MetadataService.ReadWorkflowTaskResult().getRecords(); 1058 | new MetadataService.ReadWorkflowSendResult().getRecords(); 1059 | new MetadataService.ReadWorkflowOutboundMessageResult().getRecords(); 1060 | new MetadataService.ReadWorkflowKnowledgePublishResult().getRecords(); 1061 | new MetadataService.ReadWorkflowFieldUpdateResult().getRecords(); 1062 | new MetadataService.ReadWorkflowAlertResult().getRecords(); 1063 | new MetadataService.ReadVisualizationPluginResult().getRecords(); 1064 | new MetadataService.ReadCustomMetadataResult().getRecords(); 1065 | new MetadataService.ReadNameSettingsResult().getRecords(); 1066 | new MetadataService.ReadMarketingActionSettingsResult().getRecords(); 1067 | new MetadataService.ReadCustomPermissionResult().getRecords(); 1068 | new MetadataService.ReadAuraDefinitionBundleResult().getRecords(); 1069 | new MetadataService.ReadCorsWhitelistOriginResult().getRecords(); 1070 | new MetadataService.ReadManagedTopicsResult().getRecords(); 1071 | new MetadataService.ReadTerritory2Result().getRecords(); 1072 | new MetadataService.ReadTerritory2ModelResult().getRecords(); 1073 | new MetadataService.ReadTerritory2SettingsResult().getRecords(); 1074 | new MetadataService.ReadTerritory2TypeResult().getRecords(); 1075 | new MetadataService.ReadXOrgHubResult().getRecords(); 1076 | new MetadataService.ReadActionLinkGroupTemplateResult().getRecords(); 1077 | new MetadataService.ReadLicenseDefinitionResult().getRecords(); 1078 | new MetadataService.ReadMarketingResourceTypeResult().getRecords(); 1079 | new MetadataService.ReadMatchingRuleResult().getRecords(); 1080 | new MetadataService.ReadMatchingRulesResult().getRecords(); 1081 | new MetadataService.ReadNamedCredentialResult().getRecords(); 1082 | new MetadataService.ReadPersonalJourneySettingsResult().getRecords(); 1083 | new MetadataService.ReadSharingRulesResult().getRecords(); 1084 | new MetadataService.ReadSharingBaseRuleResult().getRecords(); 1085 | new MetadataService.ReadSharingCriteriaRuleResult().getRecords(); 1086 | new MetadataService.ReadSharingOwnerRuleResult().getRecords(); 1087 | new MetadataService.ReadSharingTerritoryRuleResult().getRecords(); 1088 | new MetadataService.ReadMetadataWithContentResult().getRecords(); 1089 | new MetadataService.ReadCustomSiteResult().getRecords(); 1090 | new MetadataService.ReadListViewResult().getRecords(); 1091 | new MetadataService.ReadInstalledPackageResult().getRecords(); 1092 | new MetadataService.ReadCustomFieldResult().getRecords(); 1093 | new MetadataService.ReadFieldSetResult().getRecords(); 1094 | new MetadataService.ReadPicklistValueResult().getRecords(); 1095 | new MetadataService.ReadRecordTypeResult().getRecords(); 1096 | new MetadataService.ReadWebLinkResult().getRecords(); 1097 | new MetadataService.ReadAddressSettingsResult().getRecords(); 1098 | new MetadataService.ReadCaseSettingsResult().getRecords(); 1099 | new MetadataService.ReadCustomObjectResult().getRecords(); 1100 | new MetadataService.ReadLayoutResult().getRecords(); 1101 | new MetadataService.ReadEmailTemplateResult().getRecords(); 1102 | new MetadataService.ReadScontrolResult().getRecords(); 1103 | new MetadataService.ReadApexPageResult().getRecords(); 1104 | new MetadataService.ReadApexComponentResult().getRecords(); 1105 | new MetadataService.ReadApexClassResult().getRecords(); 1106 | new MetadataService.ReadApexTriggerResult().getRecords(); 1107 | new MetadataService.ReadStaticResourceResult().getRecords(); 1108 | new MetadataService.ReadDocumentResult().getRecords(); 1109 | new MetadataService.ReadCustomLabelsResult().getRecords(); 1110 | new MetadataService.ReadCustomLabelResult().getRecords(); 1111 | new MetadataService.ReadAccountSettingsResult().getRecords(); 1112 | new MetadataService.ReadQueueResult().getRecords(); 1113 | new MetadataService.ReadCustomDataTypeResult().getRecords(); 1114 | new MetadataService.ReadExternalDataSourceResult().getRecords(); 1115 | new MetadataService.ReadGroupResult().getRecords(); 1116 | new MetadataService.ReadBusinessProcessResult().getRecords(); 1117 | new MetadataService.ReadCompactLayoutResult().getRecords(); 1118 | new MetadataService.ReadSharingReasonResult().getRecords(); 1119 | new MetadataService.ReadValidationRuleResult().getRecords(); 1120 | new MetadataService.ReadReportTypeResult().getRecords(); 1121 | new MetadataService.ReadReportResult().getRecords(); 1122 | new MetadataService.ReadDashboardResult().getRecords(); 1123 | new MetadataService.ReadAnalyticSnapshotResult().getRecords(); 1124 | new MetadataService.ReadCustomPageWebLinkResult().getRecords(); 1125 | new MetadataService.ReadQuickActionResult().getRecords(); 1126 | new MetadataService.ReadFlexiPageResult().getRecords(); 1127 | new MetadataService.ReadCustomTabResult().getRecords(); 1128 | new MetadataService.ReadCustomApplicationComponentResult().getRecords(); 1129 | new MetadataService.ReadCustomApplicationResult().getRecords(); 1130 | new MetadataService.ReadPortalResult().getRecords(); 1131 | new MetadataService.ReadLetterheadResult().getRecords(); 1132 | new MetadataService.ReadFlowResult().getRecords(); 1133 | new MetadataService.ReadFlowResult().getRecords(); 1134 | new MetadataService.ReadDelegateGroupResult().getRecords(); 1135 | new MetadataService.ReadEventDeliveryResult().getRecords(); 1136 | new MetadataService.ReadEventSubscriptionResult().getRecords(); 1137 | new MetadataService.ReadEventTypeResult().getRecords(); 1138 | new MetadataService.ReadCertificateResult().getRecords(); 1139 | new MetadataService.ReadModerationRuleResult().getRecords(); 1140 | new MetadataService.ReadWaveApplicationResult().getRecords(); 1141 | new MetadataService.ReadWaveDatasetResult().getRecords(); 1142 | new MetadataService.ReadChannelLayoutResult().getRecords(); 1143 | new MetadataService.ReadContentAssetResult().getRecords(); 1144 | new MetadataService.ReadApexTestSuiteResult().getRecords(); 1145 | new MetadataService.ReadCustomValueResult().getRecords(); 1146 | new MetadataService.ReadStandardValueResult().getRecords(); 1147 | new MetadataService.ReadStandardValueSetResult().getRecords(); 1148 | new MetadataService.ReadGlobalPicklistValueResult().getRecords(); 1149 | new MetadataService.ReadGlobalValueSetResult().getRecords(); 1150 | new MetadataService.ReadSearchSettingsResult().getRecords(); 1151 | new MetadataService.ReadOrgPreferenceSettingsResult().getRecords(); 1152 | new MetadataService.ReadWaveLensResult().getRecords(); 1153 | new MetadataService.ReadWaveDataflowResult().getRecords(); 1154 | new MetadataService.ReadWaveDashboardResult().getRecords(); 1155 | new MetadataService.ReadEmailServicesFunctionResult().getRecords(); 1156 | new MetadataService.ReadEmbeddedServiceBrandingResult().getRecords(); 1157 | new MetadataService.ReadEmbeddedServiceConfigResult().getRecords(); 1158 | new MetadataService.ReadEmbeddedServiceLiveAgentResult().getRecords(); 1159 | new MetadataService.ReadCaseSubjectParticleResult().getRecords(); 1160 | new MetadataService.ReadNetworkBrandingResult().getRecords(); 1161 | new MetadataService.ReadSocialCustomerServiceSettingsResult().getRecords(); 1162 | new MetadataService.ReadTopicsForObjectsResult().getRecords(); 1163 | new MetadataService.ReadBrandingSetResult().getRecords(); 1164 | new MetadataService.ReadProfilePasswordPolicyResult().getRecords(); 1165 | new MetadataService.ReadProfileSessionSettingResult().getRecords(); 1166 | new MetadataService.ReadCspTrustedSiteResult().getRecords(); 1167 | new MetadataService.ReadEclairGeoDataResult().getRecords(); 1168 | new MetadataService.ReadExternalServiceRegistrationResult().getRecords(); 1169 | new MetadataService.ReadFileUploadAndDownloadSecuritySettingsResult().getRecords(); 1170 | new MetadataService.ReadLeadConvertSettingsResult().getRecords(); 1171 | new MetadataService.ReadUserCriteriaResult().getRecords(); 1172 | new MetadataService.ReadWavexmdResult().getRecords(); 1173 | Test.stopTest(); 1174 | } 1175 | 1176 | @IsTest 1177 | private static void elfMissingGetResultTest() { // elf patch 1178 | Test.startTest(); 1179 | new MetadataService.readWorkflowRuleResponse_element().getResult(); 1180 | new MetadataService.readSamlSsoConfigResponse_element().getResult(); 1181 | new MetadataService.readCustomLabelResponse_element().getResult(); 1182 | new MetadataService.readBusinessHoursEntryResponse_element().getResult(); 1183 | new MetadataService.readMobileSettingsResponse_element().getResult(); 1184 | new MetadataService.readChatterAnswersSettingsResponse_element().getResult(); 1185 | new MetadataService.readSharingRulesResponse_element().getResult(); 1186 | new MetadataService.readPortalResponse_element().getResult(); 1187 | new MetadataService.readSkillResponse_element().getResult(); 1188 | new MetadataService.readEscalationRulesResponse_element().getResult(); 1189 | new MetadataService.readCustomDataTypeResponse_element().getResult(); 1190 | new MetadataService.readExternalDataSourceResponse_element().getResult(); 1191 | new MetadataService.readEntitlementProcessResponse_element().getResult(); 1192 | new MetadataService.readRecordTypeResponse_element().getResult(); 1193 | new MetadataService.readScontrolResponse_element().getResult(); 1194 | new MetadataService.readDataCategoryGroupResponse_element().getResult(); 1195 | new MetadataService.readValidationRuleResponse_element().getResult(); 1196 | new MetadataService.readProfileResponse_element().getResult(); 1197 | new MetadataService.readIdeasSettingsResponse_element().getResult(); 1198 | new MetadataService.readConnectedAppResponse_element().getResult(); 1199 | new MetadataService.readApexPageResponse_element().getResult(); 1200 | new MetadataService.readProductSettingsResponse_element().getResult(); 1201 | new MetadataService.readLiveAgentSettingsResponse_element().getResult(); 1202 | new MetadataService.readOpportunitySettingsResponse_element().getResult(); 1203 | new MetadataService.readLiveChatDeploymentResponse_element().getResult(); 1204 | new MetadataService.readActivitiesSettingsResponse_element().getResult(); 1205 | new MetadataService.readLayoutResponse_element().getResult(); 1206 | new MetadataService.readWebLinkResponse_element().getResult(); 1207 | new MetadataService.readSiteDotComResponse_element().getResult(); 1208 | new MetadataService.readCompanySettingsResponse_element().getResult(); 1209 | new MetadataService.readHomePageLayoutResponse_element().getResult(); 1210 | new MetadataService.readDashboardResponse_element().getResult(); 1211 | new MetadataService.readAssignmentRulesResponse_element().getResult(); 1212 | new MetadataService.readAnalyticSnapshotResponse_element().getResult(); 1213 | new MetadataService.readEscalationRuleResponse_element().getResult(); 1214 | new MetadataService.readCustomSiteResponse_element().getResult(); 1215 | new MetadataService.readGroupResponse_element().getResult(); 1216 | new MetadataService.readReportTypeResponse_element().getResult(); 1217 | new MetadataService.readQuickActionResponse_element().getResult(); 1218 | new MetadataService.readCustomPageWebLinkResponse_element().getResult(); 1219 | new MetadataService.readApexComponentResponse_element().getResult(); 1220 | new MetadataService.readEntitlementTemplateResponse_element().getResult(); 1221 | new MetadataService.readFlexiPageResponse_element().getResult(); 1222 | new MetadataService.readWorkflowResponse_element().getResult(); 1223 | new MetadataService.readWorkflowActionResponse_element().getResult(); 1224 | new MetadataService.readAddressSettingsResponse_element().getResult(); 1225 | new MetadataService.readContractSettingsResponse_element().getResult(); 1226 | new MetadataService.readCustomObjectResponse_element().getResult(); 1227 | new MetadataService.readTranslationsResponse_element().getResult(); 1228 | new MetadataService.readRoleOrTerritoryResponse_element().getResult(); 1229 | new MetadataService.readApexTriggerResponse_element().getResult(); 1230 | new MetadataService.readCustomLabelsResponse_element().getResult(); 1231 | new MetadataService.readSecuritySettingsResponse_element().getResult(); 1232 | new MetadataService.readCallCenterResponse_element().getResult(); 1233 | new MetadataService.readPicklistValueResponse_element().getResult(); 1234 | new MetadataService.readRemoteSiteSettingResponse_element().getResult(); 1235 | new MetadataService.readQuoteSettingsResponse_element().getResult(); 1236 | new MetadataService.readSynonymDictionaryResponse_element().getResult(); 1237 | new MetadataService.readPostTemplateResponse_element().getResult(); 1238 | new MetadataService.readCustomTabResponse_element().getResult(); 1239 | new MetadataService.readLetterheadResponse_element().getResult(); 1240 | new MetadataService.readInstalledPackageResponse_element().getResult(); 1241 | new MetadataService.readQueueResponse_element().getResult(); 1242 | new MetadataService.readAuthProviderResponse_element().getResult(); 1243 | new MetadataService.readEntitlementSettingsResponse_element().getResult(); 1244 | new MetadataService.readCustomFieldResponse_element().getResult(); 1245 | new MetadataService.readStaticResourceResponse_element().getResult(); 1246 | new MetadataService.readEmailTemplateResponse_element().getResult(); 1247 | new MetadataService.readSharingReasonResponse_element().getResult(); 1248 | new MetadataService.readLiveChatButtonResponse_element().getResult(); 1249 | new MetadataService.readNetworkResponse_element().getResult(); 1250 | new MetadataService.readApprovalProcessResponse_element().getResult(); 1251 | new MetadataService.readMilestoneTypeResponse_element().getResult(); 1252 | new MetadataService.readAssignmentRuleResponse_element().getResult(); 1253 | new MetadataService.readCompactLayoutResponse_element().getResult(); 1254 | new MetadataService.readLiveChatAgentConfigResponse_element().getResult(); 1255 | new MetadataService.readAccountSettingsResponse_element().getResult(); 1256 | new MetadataService.readBusinessProcessResponse_element().getResult(); 1257 | new MetadataService.readFlowResponse_element().getResult(); 1258 | new MetadataService.readAutoResponseRuleResponse_element().getResult(); 1259 | new MetadataService.readPermissionSetResponse_element().getResult(); 1260 | new MetadataService.readBusinessHoursSettingsResponse_element().getResult(); 1261 | new MetadataService.readForecastingSettingsResponse_element().getResult(); 1262 | new MetadataService.readReportResponse_element().getResult(); 1263 | new MetadataService.readAppMenuResponse_element().getResult(); 1264 | new MetadataService.readListViewResponse_element().getResult(); 1265 | new MetadataService.readOrderSettingsResponse_element().getResult(); 1266 | new MetadataService.readCustomObjectTranslationResponse_element().getResult(); 1267 | new MetadataService.readCustomApplicationResponse_element().getResult(); 1268 | new MetadataService.readKnowledgeSettingsResponse_element().getResult(); 1269 | new MetadataService.readCaseSettingsResponse_element().getResult(); 1270 | new MetadataService.readApexClassResponse_element().getResult(); 1271 | new MetadataService.readPackageResponse_element().getResult(); 1272 | new MetadataService.readCommunityResponse_element().getResult(); 1273 | new MetadataService.readDocumentResponse_element().getResult(); 1274 | new MetadataService.readAutoResponseRulesResponse_element().getResult(); 1275 | new MetadataService.readFolderResponse_element().getResult(); 1276 | new MetadataService.readCustomApplicationComponentResponse_element().getResult(); 1277 | new MetadataService.readFieldSetResponse_element().getResult(); 1278 | new MetadataService.readSharingSetResponse_element().getResult(); 1279 | new MetadataService.readHomePageComponentResponse_element().getResult(); 1280 | new MetadataService.readReportFolderResponse_element().getResult(); 1281 | new MetadataService.readDashboardFolderResponse_element().getResult(); 1282 | new MetadataService.readFlowResponse_element().getResult(); 1283 | new MetadataService.readFlowResponse_element().getResult(); 1284 | new MetadataService.readDocumentFolderResponse_element().getResult(); 1285 | new MetadataService.readEmailFolderResponse_element().getResult(); 1286 | new MetadataService.readWorkflowTaskResponse_element().getResult(); 1287 | new MetadataService.readWorkflowSendResponse_element().getResult(); 1288 | new MetadataService.readWorkflowOutboundMessageResponse_element().getResult(); 1289 | new MetadataService.readWorkflowKnowledgePublishResponse_element().getResult(); 1290 | new MetadataService.readWorkflowFieldUpdateResponse_element().getResult(); 1291 | new MetadataService.readWorkflowAlertResponse_element().getResult(); 1292 | new MetadataService.readVisualizationPluginResponse_element().getResult(); 1293 | new MetadataService.readCustomMetadataResponse_element().getResult(); 1294 | new MetadataService.readNameSettingsResponse_element().getResult(); 1295 | new MetadataService.readMarketingActionSettingsResponse_element().getResult(); 1296 | new MetadataService.readCustomPermissionResponse_element().getResult(); 1297 | new MetadataService.readAuraDefinitionBundleResponse_element().getResult(); 1298 | new MetadataService.readCorsWhitelistOriginResponse_element().getResult(); 1299 | new MetadataService.readManagedTopicsResponse_element().getResult(); 1300 | new MetadataService.readTerritory2Response_element().getResult(); 1301 | new MetadataService.readTerritory2ModelResponse_element().getResult(); 1302 | new MetadataService.readTerritory2SettingsResponse_element().getResult(); 1303 | new MetadataService.readTerritory2TypeResponse_element().getResult(); 1304 | new MetadataService.readXOrgHubResponse_element().getResult(); 1305 | new MetadataService.readActionLinkGroupTemplateResponse_element().getResult(); 1306 | new MetadataService.readLicenseDefinitionResponse_element().getResult(); 1307 | new MetadataService.readMarketingResourceTypeResponse_element().getResult(); 1308 | new MetadataService.readMatchingRuleResponse_element().getResult(); 1309 | new MetadataService.readMatchingRulesResponse_element().getResult(); 1310 | new MetadataService.readNamedCredentialResponse_element().getResult(); 1311 | new MetadataService.readPersonalJourneySettingsResponse_element().getResult(); 1312 | new MetadataService.readSharingBaseRuleResponse_element().getResult(); 1313 | new MetadataService.readSharingCriteriaRuleResponse_element().getResult(); 1314 | new MetadataService.readSharingOwnerRuleResponse_element().getResult(); 1315 | new MetadataService.readSharingTerritoryRuleResponse_element().getResult(); 1316 | new MetadataService.readMetadataWithContentResponse_element().getResult(); 1317 | new MetadataService.readDelegateGroupResponse_element().getResult(); 1318 | new MetadataService.readEventDeliveryResponse_element().getResult(); 1319 | new MetadataService.readEventSubscriptionResponse_element().getResult(); 1320 | new MetadataService.readEventTypeResponse_element().getResult(); 1321 | new MetadataService.readCertificateResponse_element().getResult(); 1322 | new MetadataService.readModerationRuleResponse_element().getResult(); 1323 | new MetadataService.readWaveApplicationResponse_element().getResult(); 1324 | new MetadataService.readWaveDatasetResponse_element().getResult(); 1325 | new MetaDataService.readWaveDataflowResponse_element().getResult(); 1326 | new MetaDataService.readWaveLensResponse_element().getResult(); 1327 | new MetaDataService.readOrgPreferenceSettingsResponse_element().getResult(); 1328 | new MetaDataService.readSearchSettingsResponse_element().getResult(); 1329 | new MetadataService.readGlobalPicklistValueResponse_element().getResult(); 1330 | new MetadataService.readPicklistValueResponse_element().getResult(); 1331 | new MetadataService.readContentAssetResponse_element().getResult(); 1332 | new MetadataService.readChannelLayoutResponse_element().getResult(); 1333 | new MetadataService.readApexTestSuiteResponse_element().getResult(); 1334 | new MetadataService.readCustomValueResponse_element().getResult(); 1335 | new MetadataService.readStandardValueResponse_element().getResult(); 1336 | new MetadataService.readStandardValueSetResponse_element().getResult(); 1337 | new MetadataService.readGlobalValueSetResponse_element().getResult(); 1338 | new MetadataService.readWaveDashboardResponse_element().getResult(); 1339 | new MetadataService.readEmailServicesFunctionResponse_element().getResult(); 1340 | new MetadataService.readEmbeddedServiceBrandingResponse_element().getResult(); 1341 | new MetadataService.readEmbeddedServiceConfigResponse_element().getResult(); 1342 | new MetadataService.readEmbeddedServiceLiveAgentResponse_element().getResult(); 1343 | new MetadataService.readCaseSubjectParticleResponse_element().getResult(); 1344 | new MetadataService.readNetworkBrandingResponse_element().getResult(); 1345 | new MetadataService.readSocialCustomerServiceSettingsResponse_element().getResult(); 1346 | new MetadataService.readTopicsForObjectsResponse_element().getResult(); 1347 | new MetadataService.readBrandingSetResponse_element().getResult(); 1348 | new MetadataService.readProfilePasswordPolicyResponse_element().getResult(); 1349 | new MetadataService.readProfileSessionSettingResponse_element().getResult(); 1350 | new MetadataService.readCspTrustedSiteResponse_element().getResult(); 1351 | new MetadataService.readEclairGeoDataResponse_element().getResult(); 1352 | new MetadataService.readExternalServiceRegistrationResponse_element().getResult(); 1353 | new MetadataService.readFileUploadAndDownloadSecuritySettingsResponse_element().getResult(); 1354 | new MetadataService.readLeadConvertSettingsResponse_element().getResult(); 1355 | new MetadataService.readUserCriteriaResponse_element().getResult(); 1356 | new MetadataService.readWavexmdResponse_element().getResult(); 1357 | Test.stopTest(); 1358 | } 1359 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/MetadataServiceTest.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/RemoteSiteHelperController.cls: -------------------------------------------------------------------------------- 1 | global class RemoteSiteHelperController { 2 | 3 | public String Host {get;set;} 4 | global String rssNameString {get;set;} 5 | public String MetadataResponse {get;set;} 6 | public Boolean MetadataConnectionWarning {get;set;} 7 | public String MetadataApiException {get;set;} 8 | global static Exception LastMetadataAPIConnectionException {get; private set;} 9 | 10 | global RemoteSiteHelperController() { 11 | Host = ApexPages.currentPage().getHeaders().get('Host'); 12 | 13 | // Attempt to connect to the Metadata API 14 | MetadataConnectionWarning = false; 15 | if(!RemoteSiteHelperController.checkMetadataAPIConnection()) 16 | { 17 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Unable to connect to the Salesforce Metadata API.')); 18 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'A Remote Site Setting must be created in your org before you can use this tool.')); 19 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Press the Create Remote Site Setting button to perform this step or refer to the post install step below to perform this manually.')); 20 | MetadataConnectionWarning = true; 21 | MetadataApiException = ''; 22 | if(RemoteSiteHelperController.LastMetadataAPIConnectionException!=null) 23 | MetadataApiException = RemoteSiteHelperController.LastMetadataAPIConnectionException.getMessage(); 24 | } 25 | 26 | } 27 | 28 | public PageReference displayMetadataResponse() 29 | { 30 | // Display the response from the client side Metadata API callout 31 | if(metadataResponse.length()==0) 32 | { 33 | String infoString = String.format('Remote Site Setting {0} has been created.',new String[]{rssNameString}); 34 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, infoString)); 35 | MetadataConnectionWarning = false; 36 | } 37 | else 38 | { 39 | ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, metadataResponse)); 40 | MetadataConnectionWarning = true; 41 | } 42 | return null; 43 | } 44 | 45 | global static Boolean checkMetadataAPIConnection() 46 | { 47 | try { 48 | MetadataService.MetadataPort service = new MetadataService.MetadataPort(); 49 | service.SessionHeader = new MetadataService.SessionHeader_element(); 50 | service.SessionHeader.sessionId = UserInfo.getSessionId(); 51 | List queries = new List(); 52 | MetadataService.ListMetadataQuery remoteSites = new MetadataService.ListMetadataQuery(); 53 | remoteSites.type_x = 'RemoteSiteSetting'; 54 | queries.add(remoteSites); 55 | service.listMetadata(queries, 28); 56 | } catch (Exception e) { 57 | LastMetadataAPIConnectionException = e; 58 | return false; 59 | } 60 | LastMetadataAPIConnectionException = null; 61 | return true; 62 | } 63 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/RemoteSiteHelperController.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/classes/RemoteSiteHelperTest.cls: -------------------------------------------------------------------------------- 1 | @IsTest 2 | private class RemoteSiteHelperTest 3 | { 4 | @IsTest 5 | private static void testCheckMetadataAPIConnection() 6 | { 7 | // Metadata API web Service mock implementation for tests 8 | Test.setMock(WebServiceMock.class, new WebServiceMockImpl()); 9 | 10 | RemoteSiteHelperController controller = new RemoteSiteHelperController(); 11 | System.assertEquals(true, controller.MetadataConnectionWarning); 12 | controller.MetadataResponse = ''; 13 | controller.displayMetadataResponse(); 14 | System.assertEquals(false, controller.MetadataConnectionWarning); 15 | controller.MetadataResponse = 'Some Error Creating Remote Site Setting'; 16 | controller.displayMetadataResponse(); 17 | System.assertEquals(true, controller.MetadataConnectionWarning); 18 | } 19 | 20 | /** 21 | * Metadata API web service mock class for tests above 22 | **/ 23 | private class WebServiceMockImpl implements WebServiceMock 24 | { 25 | public void doInvoke( 26 | Object stub, Object request, Map response, 27 | String endpoint, String soapAction, String requestName, 28 | String responseNS, String responseName, String responseType) 29 | { 30 | throw new TestException(); 31 | } 32 | } 33 | 34 | public class TestException extends Exception { } 35 | } -------------------------------------------------------------------------------- /apex-mdapi/src/classes/RemoteSiteHelperTest.cls-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 42.0 4 | Active 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/remotesitehelper.component: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |

Important Post Install Step:

68 |

In order to utilise the features of this tool, you need to permit the tool access to the Salesforce Metadata API. This can be accomplished by adding a Remote Site Setting with this Salesforce Server URL https://{!Host}

69 |

Click the Create Remote Site Setting button to have the tool perform this step for you.

70 | 71 |
72 |

Overview: {!pageOverview}

73 |

Link: {!pageOverviewLinkText}

74 | 75 | 76 |

DEBUG USE ONLY: {!metadataApiException}

77 |
78 |
79 | 80 |
-------------------------------------------------------------------------------- /apex-mdapi/src/components/remotesitehelper.component-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/unzip.component: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 66 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/unzip.component-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/zip.component: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 35 | 36 | 37 | 46 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/zip.component-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/zipEntry.component: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 34 | -------------------------------------------------------------------------------- /apex-mdapi/src/components/zipEntry.component-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/documents/MetadataServicePatcher-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Public 4 | MetadataServicePatcher 5 | ReadWrite 6 | 7 | -------------------------------------------------------------------------------- /apex-mdapi/src/documents/MetadataServicePatcher/MetadataServicePatchedCopy-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | false 4 | MetadataService 5 | false 6 | 7 | -------------------------------------------------------------------------------- /apex-mdapi/src/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | MetadataDataController 5 | MetadataDeployController 6 | MetadataRetrieveController 7 | MetadataService 8 | MetadataServiceExamples 9 | MetadataServicePatcher 10 | MetadataServiceTest 11 | RemoteSiteHelperController 12 | RemoteSiteHelperTest 13 | ApexClass 14 | 15 | 16 | remotesitehelper 17 | unzip 18 | zip 19 | zipEntry 20 | ApexComponent 21 | 22 | 23 | metadatabrowser 24 | metadatadata 25 | metadatadeploy 26 | metadataretrieve 27 | remotesitepage 28 | ApexPage 29 | 30 | 31 | MetadataBrowser 32 | MetadataDeployDemo 33 | MetadataRetrieveDemo 34 | CustomTab 35 | 36 | 37 | MetadataServicePatcher 38 | MetadataServicePatcher/MetadataServicePatchedCopy 39 | Document 40 | 41 | 42 | extjs 43 | jszip 44 | StaticResource 45 | 46 | 42.0 47 | 48 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatabrowser.page: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 89 | 90 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatabrowser.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatadata.page: -------------------------------------------------------------------------------- 1 | 28 | {!Data} -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatadata.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatadeploy.page: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadatadeploy.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadataretrieve.page: -------------------------------------------------------------------------------- 1 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | {!MetaDataRetrieveZip} 69 | 70 | 71 | 72 | 73 | 74 | 75 |
{!file.content}
76 |
77 |
78 |
79 |
80 |
81 |
-------------------------------------------------------------------------------- /apex-mdapi/src/pages/metadataretrieve.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/remotesitepage.page: -------------------------------------------------------------------------------- 1 | 2 | 10 | -------------------------------------------------------------------------------- /apex-mdapi/src/pages/remotesitepage.page-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 38.0 4 | 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/staticresources/extjs.resource: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/apex-mdapi/src/staticresources/extjs.resource -------------------------------------------------------------------------------- /apex-mdapi/src/staticresources/extjs.resource-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private 4 | application/zip 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/staticresources/jszip.resource: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/apex-mdapi/src/staticresources/jszip.resource -------------------------------------------------------------------------------- /apex-mdapi/src/staticresources/jszip.resource-meta.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Private 4 | application/zip 5 | 6 | -------------------------------------------------------------------------------- /apex-mdapi/src/tabs/MetadataBrowser.tab: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Custom67: Gears 6 | metadatabrowser 7 | 8 | -------------------------------------------------------------------------------- /apex-mdapi/src/tabs/MetadataDeployDemo.tab: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Custom67: Gears 6 | metadatadeploy 7 | 8 | -------------------------------------------------------------------------------- /apex-mdapi/src/tabs/MetadataRetrieveDemo.tab: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | Custom67: Gears 6 | metadataretrieve 7 | 8 | -------------------------------------------------------------------------------- /images/mdbrowsedemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/images/mdbrowsedemo.png -------------------------------------------------------------------------------- /images/mddeploydemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/images/mddeploydemo.png -------------------------------------------------------------------------------- /images/mdretrievedemo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/images/mdretrievedemo.png -------------------------------------------------------------------------------- /images/remotesitehelper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/images/remotesitehelper.png -------------------------------------------------------------------------------- /images/showcase-layouteditingviamdapi.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/certinia/apex-mdapi/3125fc23267096c297e0e2c266cbeee62cc8336e/images/showcase-layouteditingviamdapi.png --------------------------------------------------------------------------------