{"action":"created","comment":{"url":"https://api.github.com/repos/wso2/product-apim/pulls/comments/36619933","id":36619933,"diff_hunk":"@@ -425,66 +429,115 @@ public static void exportSequences(API api, APIIdentifier apiIdentifier, int ten\n                     apiIdentifier.getVersion());\n             createDirectory(archivePath + File.separator + \"Sequences\");\n \n-            try {\n-                String sequenceName;\n-                String direction;\n-                OMElement sequenceConfig;\n-                for (Map.Entry<String, String> sequence : sequences.entrySet()) {\n-                    sequenceName = sequence.getValue();\n-                    direction = sequence.getKey();\n-                    if (sequenceName != null) {\n-                        if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN.equalsIgnoreCase(direction)) {\n-                            sequenceConfig = APIUtil.getCustomSequence(sequenceName, tenantId,\n-                                    APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN);\n-                            writeSequenceToFile(sequenceConfig, sequenceName, APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN,\n-                                    apiIdentifier);\n-                        } else if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT.equalsIgnoreCase(direction)) {\n-                            sequenceConfig = APIUtil.getCustomSequence(sequenceName, tenantId,\n-                                    APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT);\n-                            writeSequenceToFile(sequenceConfig, sequenceName, APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT,\n-                                    apiIdentifier);\n-                        } else {\n-                            sequenceConfig = APIUtil.getCustomSequence(sequenceName, tenantId,\n-                                    APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT);\n-                            writeSequenceToFile(sequenceConfig, sequenceName,\n-                                    APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT, apiIdentifier);\n-                        }\n+            String sequenceName;\n+            String direction;\n+            for (Map.Entry<String, String> sequence : sequences.entrySet()) {\n+                sequenceName = sequence.getValue();\n+                direction = sequence.getKey();\n+                AbstractMap.SimpleEntry<String, OMElement> sequenceDetails;\n+                if (sequenceName != null) {\n+                    if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN.equalsIgnoreCase(direction)) {\n+                        sequenceDetails = getCustomSequence(sequenceName, APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN,\n+                            registry);\n+                        writeSequenceToFile(sequenceDetails, APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN,\n+                            apiIdentifier);\n+                    } else if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT.equalsIgnoreCase(direction)) {\n+                        sequenceDetails = getCustomSequence(sequenceName, APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT,\n+                            registry);\n+                        writeSequenceToFile(sequenceDetails, APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT,\n+                            apiIdentifier);\n+                    } else {\n+                        sequenceDetails = getCustomSequence(sequenceName,\n+                            APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT, registry);\n+                        writeSequenceToFile(sequenceDetails, APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT,\n+                            apiIdentifier);\n                     }\n                 }\n-            } catch (APIManagementException e) {\n-                log.error(\"Error while retrieving custom sequence\" + e.getMessage());\n-                throw new APIExportException(\"Error while retrieving custom sequence\", e);\n+            }\n+        }\n+    }\n+\n+    /**\n+     * Retrieve custom sequence details from the registry\n+     *\n+     * @param sequenceName Name of the sequence\n+     * @param type         Sequence type\n+     * @param registry     Current tenant registry\n+     * @return Registry resource name of the sequence and its content\n+     * @throws APIExportException If an error occurs while retrieving registry elements\n+     */\n+    private static AbstractMap.SimpleEntry<String, OMElement> getCustomSequence(String sequenceName,\n+        String type, Registry registry) throws APIExportException {\n+        AbstractMap.SimpleEntry<String, OMElement> sequenceDetails;\n+\n+        org.wso2.carbon.registry.api.Collection seqCollection = null;\n+\n+        try {\n+            if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_IN.equals(type)) {\n+                seqCollection =\n+                    (org.wso2.carbon.registry.api.Collection) registry.get(APIConstants.API_CUSTOM_INSEQUENCE_LOCATION);\n+            }\n+            else if (APIConstants.API_CUSTOM_SEQUENCE_TYPE_OUT.equals(type)) {\n+                seqCollection =\n+                    (org.wso2.carbon.registry.api.Collection) registry.get(APIConstants.API_CUSTOM_OUTSEQUENCE_LOCATION);\n+            }\n+            else if(APIConstants.API_CUSTOM_SEQUENCE_TYPE_FAULT.equals(type)) {\n+                seqCollection =\n+                    (org.wso2.carbon.registry.api.Collection) registry.get(APIConstants.API_CUSTOM_FAULTSEQUENCE_LOCATION);\n+            }\n+\n+            if (seqCollection != null) {\n+                String[] childPaths = seqCollection.getChildren();\n \n+                for (int i = 0; i < childPaths.length; i++) {\n+                    Resource sequence = registry.get(childPaths[i]);\n+                    OMElement seqElment = APIUtil.buildOMElement(sequence.getContentStream());\n+                    if (sequenceName.equals(seqElment.getAttributeValue(new QName(\"name\")))) {\n+                        String sequenceFileName = sequence.getPath().substring(sequence.getPath().lastIndexOf('/'));\n+                        sequenceDetails = new AbstractMap.SimpleEntry<String, OMElement>(sequenceFileName, seqElment);\n+                        return sequenceDetails;\n+                    }\n+                }\n             }\n+\n+        } catch (RegistryException e) {\n+            log.error(\"Error while retrieving sequence from the registry \" + e.getMessage());\n+            throw new APIExportException(\"Error while retrieving sequence from the registry\", e);\n+        } catch (Exception e) {","path":"modules/api-import-export/src/main/java/apim/restful/importexport/utils/APIExportUtil.java","position":144,"original_position":144,"commit_id":"eaa74419a4c74260af5d9b28dccd5a6d83d631dc","original_commit_id":"eaa74419a4c74260af5d9b28dccd5a6d83d631dc","user":{"login":"thilinicooray","id":2269327,"avatar_url":"https://avatars.githubusercontent.com/u/2269327?v=3","gravatar_id":"","url":"https://api.github.com/users/thilinicooray","html_url":"https://github.com/thilinicooray","followers_url":"https://api.github.com/users/thilinicooray/followers","following_url":"https://api.github.com/users/thilinicooray/following{/other_user}","gists_url":"https://api.github.com/users/thilinicooray/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinicooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinicooray/subscriptions","organizations_url":"https://api.github.com/users/thilinicooray/orgs","repos_url":"https://api.github.com/users/thilinicooray/repos","events_url":"https://api.github.com/users/thilinicooray/events{/privacy}","received_events_url":"https://api.github.com/users/thilinicooray/received_events","type":"User","site_admin":false},"body":"In line 494, APIUtil.buildOMElement throws a generic exception.\r\nTherefore this clause was required to catch that exception.","created_at":"2015-08-10T10:57:46Z","updated_at":"2015-08-10T10:57:46Z","html_url":"https://github.com/wso2/product-apim/pull/305#discussion_r36619933","pull_request_url":"https://api.github.com/repos/wso2/product-apim/pulls/305","_links":{"self":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/comments/36619933"},"html":{"href":"https://github.com/wso2/product-apim/pull/305#discussion_r36619933"},"pull_request":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/305"}}},"pull_request":{"url":"https://api.github.com/repos/wso2/product-apim/pulls/305","id":41087780,"html_url":"https://github.com/wso2/product-apim/pull/305","diff_url":"https://github.com/wso2/product-apim/pull/305.diff","patch_url":"https://github.com/wso2/product-apim/pull/305.patch","issue_url":"https://api.github.com/repos/wso2/product-apim/issues/305","number":305,"state":"open","locked":false,"title":"Test case for the fix to APIMANAGER-4006","user":{"login":"thilinicooray","id":2269327,"avatar_url":"https://avatars.githubusercontent.com/u/2269327?v=3","gravatar_id":"","url":"https://api.github.com/users/thilinicooray","html_url":"https://github.com/thilinicooray","followers_url":"https://api.github.com/users/thilinicooray/followers","following_url":"https://api.github.com/users/thilinicooray/following{/other_user}","gists_url":"https://api.github.com/users/thilinicooray/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinicooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinicooray/subscriptions","organizations_url":"https://api.github.com/users/thilinicooray/orgs","repos_url":"https://api.github.com/users/thilinicooray/repos","events_url":"https://api.github.com/users/thilinicooray/events{/privacy}","received_events_url":"https://api.github.com/users/thilinicooray/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-29T05:14:29Z","updated_at":"2015-08-10T10:57:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e13d63c985441eceea3825334115aa6b56e4de99","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wso2/product-apim/pulls/305/commits","review_comments_url":"https://api.github.com/repos/wso2/product-apim/pulls/305/comments","review_comment_url":"https://api.github.com/repos/wso2/product-apim/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wso2/product-apim/issues/305/comments","statuses_url":"https://api.github.com/repos/wso2/product-apim/statuses/eaa74419a4c74260af5d9b28dccd5a6d83d631dc","head":{"label":"thilinicooray:1.9.x","ref":"1.9.x","sha":"eaa74419a4c74260af5d9b28dccd5a6d83d631dc","user":{"login":"thilinicooray","id":2269327,"avatar_url":"https://avatars.githubusercontent.com/u/2269327?v=3","gravatar_id":"","url":"https://api.github.com/users/thilinicooray","html_url":"https://github.com/thilinicooray","followers_url":"https://api.github.com/users/thilinicooray/followers","following_url":"https://api.github.com/users/thilinicooray/following{/other_user}","gists_url":"https://api.github.com/users/thilinicooray/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinicooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinicooray/subscriptions","organizations_url":"https://api.github.com/users/thilinicooray/orgs","repos_url":"https://api.github.com/users/thilinicooray/repos","events_url":"https://api.github.com/users/thilinicooray/events{/privacy}","received_events_url":"https://api.github.com/users/thilinicooray/received_events","type":"User","site_admin":false},"repo":{"id":35868081,"name":"product-apim","full_name":"thilinicooray/product-apim","owner":{"login":"thilinicooray","id":2269327,"avatar_url":"https://avatars.githubusercontent.com/u/2269327?v=3","gravatar_id":"","url":"https://api.github.com/users/thilinicooray","html_url":"https://github.com/thilinicooray","followers_url":"https://api.github.com/users/thilinicooray/followers","following_url":"https://api.github.com/users/thilinicooray/following{/other_user}","gists_url":"https://api.github.com/users/thilinicooray/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinicooray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinicooray/subscriptions","organizations_url":"https://api.github.com/users/thilinicooray/orgs","repos_url":"https://api.github.com/users/thilinicooray/repos","events_url":"https://api.github.com/users/thilinicooray/events{/privacy}","received_events_url":"https://api.github.com/users/thilinicooray/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thilinicooray/product-apim","description":"","fork":true,"url":"https://api.github.com/repos/thilinicooray/product-apim","forks_url":"https://api.github.com/repos/thilinicooray/product-apim/forks","keys_url":"https://api.github.com/repos/thilinicooray/product-apim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thilinicooray/product-apim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thilinicooray/product-apim/teams","hooks_url":"https://api.github.com/repos/thilinicooray/product-apim/hooks","issue_events_url":"https://api.github.com/repos/thilinicooray/product-apim/issues/events{/number}","events_url":"https://api.github.com/repos/thilinicooray/product-apim/events","assignees_url":"https://api.github.com/repos/thilinicooray/product-apim/assignees{/user}","branches_url":"https://api.github.com/repos/thilinicooray/product-apim/branches{/branch}","tags_url":"https://api.github.com/repos/thilinicooray/product-apim/tags","blobs_url":"https://api.github.com/repos/thilinicooray/product-apim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thilinicooray/product-apim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thilinicooray/product-apim/git/refs{/sha}","trees_url":"https://api.github.com/repos/thilinicooray/product-apim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thilinicooray/product-apim/statuses/{sha}","languages_url":"https://api.github.com/repos/thilinicooray/product-apim/languages","stargazers_url":"https://api.github.com/repos/thilinicooray/product-apim/stargazers","contributors_url":"https://api.github.com/repos/thilinicooray/product-apim/contributors","subscribers_url":"https://api.github.com/repos/thilinicooray/product-apim/subscribers","subscription_url":"https://api.github.com/repos/thilinicooray/product-apim/subscription","commits_url":"https://api.github.com/repos/thilinicooray/product-apim/commits{/sha}","git_commits_url":"https://api.github.com/repos/thilinicooray/product-apim/git/commits{/sha}","comments_url":"https://api.github.com/repos/thilinicooray/product-apim/comments{/number}","issue_comment_url":"https://api.github.com/repos/thilinicooray/product-apim/issues/comments{/number}","contents_url":"https://api.github.com/repos/thilinicooray/product-apim/contents/{+path}","compare_url":"https://api.github.com/repos/thilinicooray/product-apim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thilinicooray/product-apim/merges","archive_url":"https://api.github.com/repos/thilinicooray/product-apim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thilinicooray/product-apim/downloads","issues_url":"https://api.github.com/repos/thilinicooray/product-apim/issues{/number}","pulls_url":"https://api.github.com/repos/thilinicooray/product-apim/pulls{/number}","milestones_url":"https://api.github.com/repos/thilinicooray/product-apim/milestones{/number}","notifications_url":"https://api.github.com/repos/thilinicooray/product-apim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thilinicooray/product-apim/labels{/name}","releases_url":"https://api.github.com/repos/thilinicooray/product-apim/releases{/id}","created_at":"2015-05-19T08:03:47Z","updated_at":"2015-05-19T08:03:57Z","pushed_at":"2015-08-10T07:04:27Z","git_url":"git://github.com/thilinicooray/product-apim.git","ssh_url":"git@github.com:thilinicooray/product-apim.git","clone_url":"https://github.com/thilinicooray/product-apim.git","svn_url":"https://github.com/thilinicooray/product-apim","homepage":null,"size":66472,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"wso2:1.9.x","ref":"1.9.x","sha":"a156564c8727a46e2d3b436489fbe27633bf946f","user":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"repo":{"id":20717348,"name":"product-apim","full_name":"wso2/product-apim","owner":{"login":"wso2","id":533043,"avatar_url":"https://avatars.githubusercontent.com/u/533043?v=3","gravatar_id":"","url":"https://api.github.com/users/wso2","html_url":"https://github.com/wso2","followers_url":"https://api.github.com/users/wso2/followers","following_url":"https://api.github.com/users/wso2/following{/other_user}","gists_url":"https://api.github.com/users/wso2/gists{/gist_id}","starred_url":"https://api.github.com/users/wso2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wso2/subscriptions","organizations_url":"https://api.github.com/users/wso2/orgs","repos_url":"https://api.github.com/users/wso2/repos","events_url":"https://api.github.com/users/wso2/events{/privacy}","received_events_url":"https://api.github.com/users/wso2/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wso2/product-apim","description":"","fork":false,"url":"https://api.github.com/repos/wso2/product-apim","forks_url":"https://api.github.com/repos/wso2/product-apim/forks","keys_url":"https://api.github.com/repos/wso2/product-apim/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wso2/product-apim/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wso2/product-apim/teams","hooks_url":"https://api.github.com/repos/wso2/product-apim/hooks","issue_events_url":"https://api.github.com/repos/wso2/product-apim/issues/events{/number}","events_url":"https://api.github.com/repos/wso2/product-apim/events","assignees_url":"https://api.github.com/repos/wso2/product-apim/assignees{/user}","branches_url":"https://api.github.com/repos/wso2/product-apim/branches{/branch}","tags_url":"https://api.github.com/repos/wso2/product-apim/tags","blobs_url":"https://api.github.com/repos/wso2/product-apim/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wso2/product-apim/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wso2/product-apim/git/refs{/sha}","trees_url":"https://api.github.com/repos/wso2/product-apim/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wso2/product-apim/statuses/{sha}","languages_url":"https://api.github.com/repos/wso2/product-apim/languages","stargazers_url":"https://api.github.com/repos/wso2/product-apim/stargazers","contributors_url":"https://api.github.com/repos/wso2/product-apim/contributors","subscribers_url":"https://api.github.com/repos/wso2/product-apim/subscribers","subscription_url":"https://api.github.com/repos/wso2/product-apim/subscription","commits_url":"https://api.github.com/repos/wso2/product-apim/commits{/sha}","git_commits_url":"https://api.github.com/repos/wso2/product-apim/git/commits{/sha}","comments_url":"https://api.github.com/repos/wso2/product-apim/comments{/number}","issue_comment_url":"https://api.github.com/repos/wso2/product-apim/issues/comments{/number}","contents_url":"https://api.github.com/repos/wso2/product-apim/contents/{+path}","compare_url":"https://api.github.com/repos/wso2/product-apim/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wso2/product-apim/merges","archive_url":"https://api.github.com/repos/wso2/product-apim/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wso2/product-apim/downloads","issues_url":"https://api.github.com/repos/wso2/product-apim/issues{/number}","pulls_url":"https://api.github.com/repos/wso2/product-apim/pulls{/number}","milestones_url":"https://api.github.com/repos/wso2/product-apim/milestones{/number}","notifications_url":"https://api.github.com/repos/wso2/product-apim/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wso2/product-apim/labels{/name}","releases_url":"https://api.github.com/repos/wso2/product-apim/releases{/id}","created_at":"2014-06-11T08:05:00Z","updated_at":"2015-05-08T08:25:49Z","pushed_at":"2015-08-10T10:46:51Z","git_url":"git://github.com/wso2/product-apim.git","ssh_url":"git@github.com:wso2/product-apim.git","clone_url":"https://github.com/wso2/product-apim.git","svn_url":"https://github.com/wso2/product-apim","homepage":null,"size":81218,"stargazers_count":2,"watchers_count":2,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":76,"mirror_url":null,"open_issues_count":19,"forks":76,"open_issues":19,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/305"},"html":{"href":"https://github.com/wso2/product-apim/pull/305"},"issue":{"href":"https://api.github.com/repos/wso2/product-apim/issues/305"},"comments":{"href":"https://api.github.com/repos/wso2/product-apim/issues/305/comments"},"review_comments":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/305/comments"},"review_comment":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wso2/product-apim/pulls/305/commits"},"statuses":{"href":"https://api.github.com/repos/wso2/product-apim/statuses/eaa74419a4c74260af5d9b28dccd5a6d83d631dc"}}}}