Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
b536c2d8
Commit
b536c2d8
authored
Jul 18, 2016
by
Jason Song
Committed by
GitHub
Jul 18, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #330 from lepdou/bugfix_0718
初始化private app namespace的权限放在transaction里面
parents
4c64de67
10d17f87
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
15 deletions
+17
-15
AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+2
-2
CreationListener.java
...ip/framework/apollo/portal/listener/CreationListener.java
+4
-10
AppNamespaceService.java
.../framework/apollo/portal/service/AppNamespaceService.java
+10
-2
ClusterService.java
...ctrip/framework/apollo/portal/service/ClusterService.java
+1
-1
No files found.
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
b536c2d8
...
...
@@ -82,7 +82,7 @@ public class AdminServiceAPI {
getAdminServiceHost
(
env
),
namespace
.
getAppId
(),
namespace
.
getClusterName
()).
getBody
();
}
public
AppNamespaceDTO
create
OrUpdate
AppNamespace
(
Env
env
,
AppNamespaceDTO
appNamespace
)
{
public
AppNamespaceDTO
createAppNamespace
(
Env
env
,
AppNamespaceDTO
appNamespace
)
{
return
restTemplate
.
postForEntity
(
"{host}/apps/{appId}/appnamespaces"
,
appNamespace
,
AppNamespaceDTO
.
class
,
getAdminServiceHost
(
env
),
appNamespace
.
getAppId
()).
getBody
();
}
...
...
@@ -146,7 +146,7 @@ public class AdminServiceAPI {
}
public
ClusterDTO
create
OrUpdate
(
Env
env
,
ClusterDTO
cluster
)
{
public
ClusterDTO
create
(
Env
env
,
ClusterDTO
cluster
)
{
return
restTemplate
.
postForObject
(
"{host}/apps/{appId}/clusters"
,
cluster
,
ClusterDTO
.
class
,
getAdminServiceHost
(
env
),
cluster
.
getAppId
());
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/listener/CreationListener.java
View file @
b536c2d8
...
...
@@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.event.EventListener
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
java.util.List
;
...
...
@@ -38,7 +37,7 @@ public class CreationListener {
for
(
Env
env
:
envs
)
{
try
{
appAPI
.
createApp
(
env
,
appDTO
);
}
catch
(
HttpStatusCodeException
e
)
{
}
catch
(
Throwable
e
)
{
logger
.
error
(
"call appAPI.createApp error.[{app}, {env}]"
,
appDTO
.
getAppId
(),
env
,
e
);
}
}
...
...
@@ -50,16 +49,11 @@ public class CreationListener {
List
<
Env
>
envs
=
portalSettings
.
getActiveEnvs
();
for
(
Env
env
:
envs
)
{
try
{
namespaceAPI
.
create
OrUpdate
AppNamespace
(
env
,
dto
);
}
catch
(
HttpStatusCodeException
e
)
{
logger
.
error
(
"call namespaceAPI.create
OrUpdate
AppNamespace error. [{app}, {env}]"
,
dto
.
getAppId
(),
env
,
e
);
namespaceAPI
.
createAppNamespace
(
env
,
dto
);
}
catch
(
Throwable
e
)
{
logger
.
error
(
"call namespaceAPI.createAppNamespace error. [{app}, {env}]"
,
dto
.
getAppId
(),
env
,
e
);
}
}
//如果是私有的app namespace 要默认初始化权限
if
(!
dto
.
isPublic
())
{
roleInitializationService
.
initNamespaceRoles
(
dto
.
getAppId
(),
dto
.
getName
());
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/AppNamespaceService.java
View file @
b536c2d8
...
...
@@ -22,7 +22,8 @@ public class AppNamespaceService {
private
UserInfoHolder
userInfoHolder
;
@Autowired
private
AppNamespaceRepository
appNamespaceRepository
;
@Autowired
private
RoleInitializationService
roleInitializationService
;
/**
* 公共的app ns,能被其它项目关联到的app ns
...
...
@@ -74,7 +75,14 @@ public class AppNamespaceService {
throw
new
BadRequestException
(
appNamespace
.
getName
()
+
"已存在"
);
}
return
appNamespaceRepository
.
save
(
appNamespace
);
AppNamespace
createdAppNamespace
=
appNamespaceRepository
.
save
(
appNamespace
);
//如果是私有的app namespace 要默认初始化权限,如果是公共的,则在关联此namespace的时候初始化权限
if
(!
createdAppNamespace
.
isPublic
())
{
roleInitializationService
.
initNamespaceRoles
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
());
}
return
createdAppNamespace
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ClusterService.java
View file @
b536c2d8
...
...
@@ -24,7 +24,7 @@ public class ClusterService {
if
(!
clusterAPI
.
isClusterUnique
(
cluster
.
getAppId
(),
env
,
cluster
.
getName
())){
throw
new
BadRequestException
(
String
.
format
(
"cluster %s already exists."
,
cluster
.
getName
()));
}
return
clusterAPI
.
create
OrUpdate
(
env
,
cluster
);
return
clusterAPI
.
create
(
env
,
cluster
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment