Unverified Commit bedd16df by Sam Padgett Committed by GitHub

Merge pull request #260 from dtaylor113/project-service-update

ProjectsService:  Added 'opts.skipErrorNotFound' handling
parents 5dbf7fe0 91506a69
...@@ -3169,7 +3169,7 @@ angular.module('openshiftCommonServices') ...@@ -3169,7 +3169,7 @@ angular.module('openshiftCommonServices')
}; };
return { return {
get: function(projectName) { get: function(projectName, opts) {
return AuthService return AuthService
.withUser() .withUser()
.then(function() { .then(function() {
...@@ -3197,6 +3197,9 @@ angular.module('openshiftCommonServices') ...@@ -3197,6 +3197,9 @@ angular.module('openshiftCommonServices')
}); });
}, function(e) { }, function(e) {
context.projectPromise.reject(e); context.projectPromise.reject(e);
if ((e.status === 403 || e.status === 404) && _.get(opts, 'skipErrorNotFound')) {
return $q.reject({notFound: true});
}
var description = 'The project could not be loaded.'; var description = 'The project could not be loaded.';
var type = 'error'; var type = 'error';
if(e.status === 403) { if(e.status === 403) {
......
...@@ -5219,7 +5219,7 @@ angular.module('openshiftCommonServices') ...@@ -5219,7 +5219,7 @@ angular.module('openshiftCommonServices')
}; };
return { return {
get: function(projectName) { get: function(projectName, opts) {
return AuthService return AuthService
.withUser() .withUser()
.then(function() { .then(function() {
...@@ -5247,6 +5247,9 @@ angular.module('openshiftCommonServices') ...@@ -5247,6 +5247,9 @@ angular.module('openshiftCommonServices')
}); });
}, function(e) { }, function(e) {
context.projectPromise.reject(e); context.projectPromise.reject(e);
if ((e.status === 403 || e.status === 404) && _.get(opts, 'skipErrorNotFound')) {
return $q.reject({notFound: true});
}
var description = 'The project could not be loaded.'; var description = 'The project could not be loaded.';
var type = 'error'; var type = 'error';
if(e.status === 403) { if(e.status === 403) {
......
...@@ -2336,7 +2336,7 @@ resource.metadata.annotations[path] || delete resource.metadata.annotations[path ...@@ -2336,7 +2336,7 @@ resource.metadata.annotations[path] || delete resource.metadata.annotations[path
}), resource; }), resource;
}; };
return { return {
get:function(projectName) { get:function(projectName, opts) {
return AuthService.withUser().then(function() { return AuthService.withUser().then(function() {
var context = { var context = {
projectPromise:$.Deferred(), projectPromise:$.Deferred(),
...@@ -2350,7 +2350,9 @@ return AuthorizationService.getProjectRules(projectName).then(function() { ...@@ -2350,7 +2350,9 @@ return AuthorizationService.getProjectRules(projectName).then(function() {
return context.project = project, context.projectPromise.resolve(project), RecentlyViewedProjectsService.addProjectUID(project.metadata.uid), cachedProjectData && cachedProjectData.update(project, "MODIFIED"), [ project, context ]; return context.project = project, context.projectPromise.resolve(project), RecentlyViewedProjectsService.addProjectUID(project.metadata.uid), cachedProjectData && cachedProjectData.update(project, "MODIFIED"), [ project, context ];
}); });
}, function(e) { }, function(e) {
context.projectPromise.reject(e); if (context.projectPromise.reject(e), (403 === e.status || 404 === e.status) && _.get(opts, "skipErrorNotFound")) return $q.reject({
notFound:!0
});
var description = "The project could not be loaded.", type = "error"; var description = "The project could not be loaded.", type = "error";
return 403 === e.status ? (description = "The project " + context.projectName + " does not exist or you are not authorized to view it.", type = "access_denied") :404 === e.status && (description = "The project " + context.projectName + " does not exist.", type = "not_found"), $location.url(URI("error").query({ return 403 === e.status ? (description = "The project " + context.projectName + " does not exist or you are not authorized to view it.", type = "access_denied") :404 === e.status && (description = "The project " + context.projectName + " does not exist.", type = "not_found"), $location.url(URI("error").query({
error:type, error:type,
......
...@@ -42,7 +42,7 @@ angular.module('openshiftCommonServices') ...@@ -42,7 +42,7 @@ angular.module('openshiftCommonServices')
}; };
return { return {
get: function(projectName) { get: function(projectName, opts) {
return AuthService return AuthService
.withUser() .withUser()
.then(function() { .then(function() {
...@@ -70,6 +70,9 @@ angular.module('openshiftCommonServices') ...@@ -70,6 +70,9 @@ angular.module('openshiftCommonServices')
}); });
}, function(e) { }, function(e) {
context.projectPromise.reject(e); context.projectPromise.reject(e);
if ((e.status === 403 || e.status === 404) && _.get(opts, 'skipErrorNotFound')) {
return $q.reject({notFound: true});
}
var description = 'The project could not be loaded.'; var description = 'The project could not be loaded.';
var type = 'error'; var type = 'error';
if(e.status === 403) { if(e.status === 403) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment