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
1b7a4aa0
Commit
1b7a4aa0
authored
Jul 11, 2016
by
Jason Song
Committed by
GitHub
Jul 11, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #319 from lepdou/bugfix_0711
Bugfix
parents
2aa333d8
5395c802
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
27 deletions
+45
-27
AppNamespaceService.java
...rip/framework/apollo/biz/service/AppNamespaceService.java
+19
-15
NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+4
-0
NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+1
-3
ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+21
-9
No files found.
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/AppNamespaceService.java
View file @
1b7a4aa0
...
@@ -31,6 +31,8 @@ public class AppNamespaceService {
...
@@ -31,6 +31,8 @@ public class AppNamespaceService {
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@Autowired
@Autowired
private
AuditService
auditService
;
private
AuditService
auditService
;
@Autowired
private
ServerConfigService
serverConfigService
;
public
boolean
isAppNamespaceNameUnique
(
String
appId
,
String
namespaceName
)
{
public
boolean
isAppNamespaceNameUnique
(
String
appId
,
String
namespaceName
)
{
Objects
.
requireNonNull
(
appId
,
"AppId must not be null"
);
Objects
.
requireNonNull
(
appId
,
"AppId must not be null"
);
...
@@ -80,23 +82,12 @@ public class AppNamespaceService {
...
@@ -80,23 +82,12 @@ public class AppNamespaceService {
appNamespace
.
setDataChangeCreatedBy
(
createBy
);
appNamespace
.
setDataChangeCreatedBy
(
createBy
);
appNamespace
.
setDataChangeLastModifiedBy
(
createBy
);
appNamespace
.
setDataChangeLastModifiedBy
(
createBy
);
appNamespace
=
appNamespaceRepository
.
save
(
appNamespace
);
appNamespace
=
appNamespaceRepository
.
save
(
appNamespace
);
//所有的cluster下面link新建的appnamespace
if
(!
appNamespace
.
isPublic
()){
String
appId
=
appNamespace
.
getAppId
();
String
namespaceName
=
appNamespace
.
getName
();
List
<
Cluster
>
clusters
=
clusterService
.
findClusters
(
appId
);
for
(
Cluster
cluster:
clusters
){
Namespace
namespace
=
new
Namespace
();
namespace
.
setClusterName
(
cluster
.
getName
());
namespace
.
setAppId
(
appId
);
namespace
.
setNamespaceName
(
namespaceName
);
namespace
.
setDataChangeCreatedBy
(
createBy
);
namespace
.
setDataChangeLastModifiedBy
(
createBy
);
namespaceService
.
save
(
namespace
);
}
//// TODO: 16/7/11 上线完删除开关逻辑
if
(
"true"
.
equals
(
serverConfigService
.
getValue
(
"appnamespace.private.enable"
,
"false"
))
&&
!
appNamespace
.
isPublic
())
{
linkPrivateAppNamespaceInAllCluster
(
appNamespace
.
getAppId
(),
appNamespace
.
getName
(),
createBy
);
}
}
auditService
.
audit
(
AppNamespace
.
class
.
getSimpleName
(),
appNamespace
.
getId
(),
Audit
.
OP
.
INSERT
,
auditService
.
audit
(
AppNamespace
.
class
.
getSimpleName
(),
appNamespace
.
getId
(),
Audit
.
OP
.
INSERT
,
createBy
);
createBy
);
return
appNamespace
;
return
appNamespace
;
...
@@ -111,4 +102,17 @@ public class AppNamespaceService {
...
@@ -111,4 +102,17 @@ public class AppNamespaceService {
return
managedNs
;
return
managedNs
;
}
}
private
void
linkPrivateAppNamespaceInAllCluster
(
String
appId
,
String
namespaceName
,
String
createBy
)
{
List
<
Cluster
>
clusters
=
clusterService
.
findClusters
(
appId
);
for
(
Cluster
cluster
:
clusters
)
{
Namespace
namespace
=
new
Namespace
();
namespace
.
setClusterName
(
cluster
.
getName
());
namespace
.
setAppId
(
appId
);
namespace
.
setNamespaceName
(
namespaceName
);
namespace
.
setDataChangeCreatedBy
(
createBy
);
namespace
.
setDataChangeLastModifiedBy
(
createBy
);
namespaceService
.
save
(
namespace
);
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
1b7a4aa0
...
@@ -15,6 +15,7 @@ import com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent;
...
@@ -15,6 +15,7 @@ import com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -50,6 +51,8 @@ public class NamespaceController {
...
@@ -50,6 +51,8 @@ public class NamespaceController {
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@Autowired
@Autowired
private
AppNamespaceService
appNamespaceService
;
private
AppNamespaceService
appNamespaceService
;
@Autowired
private
RoleInitializationService
roleInitializationService
;
@RequestMapping
(
"/appnamespaces/public"
)
@RequestMapping
(
"/appnamespaces/public"
)
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
...
@@ -62,6 +65,7 @@ public class NamespaceController {
...
@@ -62,6 +65,7 @@ public class NamespaceController {
@RequestBody
List
<
NamespaceCreationModel
>
models
)
{
@RequestBody
List
<
NamespaceCreationModel
>
models
)
{
checkModel
(!
CollectionUtils
.
isEmpty
(
models
));
checkModel
(!
CollectionUtils
.
isEmpty
(
models
));
roleInitializationService
.
initNamespaceRoles
(
appId
,
models
.
get
(
0
).
getNamespace
().
getNamespaceName
());
for
(
NamespaceCreationModel
model
:
models
)
{
for
(
NamespaceCreationModel
model
:
models
)
{
NamespaceDTO
namespace
=
model
.
getNamespace
();
NamespaceDTO
namespace
=
model
.
getNamespace
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
1b7a4aa0
...
@@ -43,8 +43,7 @@ public class NamespaceService {
...
@@ -43,8 +43,7 @@ public class NamespaceService {
@Autowired
@Autowired
private
AdminServiceAPI
.
NamespaceAPI
namespaceAPI
;
private
AdminServiceAPI
.
NamespaceAPI
namespaceAPI
;
@Autowired
private
RoleInitializationService
roleInitializationService
;
@Autowired
@Autowired
private
AppNamespaceService
appNamespaceService
;
private
AppNamespaceService
appNamespaceService
;
...
@@ -57,7 +56,6 @@ public class NamespaceService {
...
@@ -57,7 +56,6 @@ public class NamespaceService {
namespace
.
setDataChangeLastModifiedBy
(
userInfoHolder
.
getUser
().
getUserId
());
namespace
.
setDataChangeLastModifiedBy
(
userInfoHolder
.
getUser
().
getUserId
());
NamespaceDTO
createdNamespace
=
namespaceAPI
.
createNamespace
(
env
,
namespace
);
NamespaceDTO
createdNamespace
=
namespaceAPI
.
createNamespace
(
env
,
namespace
);
roleInitializationService
.
initNamespaceRoles
(
namespace
.
getAppId
(),
namespace
.
getNamespaceName
());
return
createdNamespace
;
return
createdNamespace
;
}
}
...
...
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigNamespaceController.js
View file @
1b7a4aa0
...
@@ -144,23 +144,24 @@ application_module.controller("ConfigNamespaceController",
...
@@ -144,23 +144,24 @@ application_module.controller("ConfigNamespaceController",
$scope
.
tableViewOperType
=
''
,
$scope
.
item
=
{};
$scope
.
tableViewOperType
=
''
,
$scope
.
item
=
{};
var
toOperationNamespace
;
//查看配置
//查看配置
function
retrieveItem
(
namespace
,
item
,
oldValue
)
{
function
retrieveItem
(
namespace
,
item
,
oldValue
)
{
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
RETRIEVE
);
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
RETRIEVE
);
$scope
.
item
=
item
;
$scope
.
item
=
item
;
$scope
.
item
.
oldValue
=
oldValue
;
$scope
.
item
.
oldValue
=
oldValue
;
toOperationNamespace
Name
=
namespace
.
namespace
.
namespaceNam
e
;
toOperationNamespace
=
namespac
e
;
$scope
.
hasModifyPermission
=
namespace
.
hasModifyPermission
;
$scope
.
hasModifyPermission
=
namespace
.
hasModifyPermission
;
}
}
var
toDeleteItemId
=
0
,
toDeleteNamespace
=
{}
;
var
toDeleteItemId
=
0
;
function
preDeleteItem
(
namespace
,
itemId
)
{
function
preDeleteItem
(
namespace
,
itemId
)
{
if
(
!
lockCheck
(
namespace
)){
if
(
!
lockCheck
(
namespace
)){
return
;
return
;
}
}
to
Delete
Namespace
=
namespace
;
to
Operation
Namespace
=
namespace
;
toDeleteItemId
=
itemId
;
toDeleteItemId
=
itemId
;
$
(
"#deleteConfirmDialog"
).
modal
(
"show"
);
$
(
"#deleteConfirmDialog"
).
modal
(
"show"
);
...
@@ -170,7 +171,7 @@ application_module.controller("ConfigNamespaceController",
...
@@ -170,7 +171,7 @@ application_module.controller("ConfigNamespaceController",
ConfigService
.
delete_item
(
$rootScope
.
pageContext
.
appId
,
ConfigService
.
delete_item
(
$rootScope
.
pageContext
.
appId
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
env
,
$rootScope
.
pageContext
.
clusterName
,
$rootScope
.
pageContext
.
clusterName
,
to
Delete
Namespace
.
namespace
.
namespaceName
,
to
Operation
Namespace
.
namespace
.
namespaceName
,
toDeleteItemId
).
then
(
toDeleteItemId
).
then
(
function
(
result
)
{
function
(
result
)
{
toastr
.
success
(
"删除成功!"
);
toastr
.
success
(
"删除成功!"
);
...
@@ -180,7 +181,6 @@ application_module.controller("ConfigNamespaceController",
...
@@ -180,7 +181,6 @@ application_module.controller("ConfigNamespaceController",
});
});
}
}
var
toOperationNamespaceName
=
''
;
//修改配置
//修改配置
function
editItem
(
namespace
,
item
)
{
function
editItem
(
namespace
,
item
)
{
if
(
!
lockCheck
(
namespace
)){
if
(
!
lockCheck
(
namespace
)){
...
@@ -188,7 +188,7 @@ application_module.controller("ConfigNamespaceController",
...
@@ -188,7 +188,7 @@ application_module.controller("ConfigNamespaceController",
}
}
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
UPDATE
);
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
UPDATE
);
$scope
.
item
=
item
;
$scope
.
item
=
item
;
toOperationNamespace
Name
=
namespace
.
namespace
.
namespaceNam
e
;
toOperationNamespace
=
namespac
e
;
$
(
"#itemModal"
).
modal
(
"show"
);
$
(
"#itemModal"
).
modal
(
"show"
);
}
}
...
@@ -201,7 +201,7 @@ application_module.controller("ConfigNamespaceController",
...
@@ -201,7 +201,7 @@ application_module.controller("ConfigNamespaceController",
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
CREATE
);
switchTableViewOperType
(
TABLE_VIEW_OPER_TYPE
.
CREATE
);
$scope
.
item
=
{};
$scope
.
item
=
{};
toOperationNamespace
Name
=
namespace
.
namespace
.
namespaceNam
e
;
toOperationNamespace
=
namespac
e
;
$
(
'#itemModal'
).
modal
(
'show'
);
$
(
'#itemModal'
).
modal
(
'show'
);
}
}
...
@@ -225,11 +225,23 @@ application_module.controller("ConfigNamespaceController",
...
@@ -225,11 +225,23 @@ application_module.controller("ConfigNamespaceController",
}
}
selectedClusters
.
forEach
(
function
(
cluster
)
{
selectedClusters
.
forEach
(
function
(
cluster
)
{
if
(
$scope
.
tableViewOperType
==
TABLE_VIEW_OPER_TYPE
.
CREATE
)
{
if
(
$scope
.
tableViewOperType
==
TABLE_VIEW_OPER_TYPE
.
CREATE
)
{
//check key unique
var
hasRepeatKey
=
false
;
toOperationNamespace
.
items
.
forEach
(
function
(
item
)
{
if
(
$scope
.
item
.
key
==
item
.
item
.
key
){
toastr
.
error
(
"key="
+
$scope
.
item
.
key
+
" 已存在"
);
hasRepeatKey
=
true
;
return
;
}
});
if
(
hasRepeatKey
){
return
;
}
ConfigService
.
create_item
(
$rootScope
.
pageContext
.
appId
,
ConfigService
.
create_item
(
$rootScope
.
pageContext
.
appId
,
cluster
.
env
,
cluster
.
env
,
cluster
.
name
,
cluster
.
name
,
toOperationNamespaceName
,
toOperationNamespace
.
namespace
.
namespace
Name
,
$scope
.
item
).
then
(
$scope
.
item
).
then
(
function
(
result
)
{
function
(
result
)
{
toastr
.
success
(
cluster
.
env
+
" , "
+
$scope
.
item
.
key
,
toastr
.
success
(
cluster
.
env
+
" , "
+
$scope
.
item
.
key
,
...
@@ -248,7 +260,7 @@ application_module.controller("ConfigNamespaceController",
...
@@ -248,7 +260,7 @@ application_module.controller("ConfigNamespaceController",
ConfigService
.
update_item
(
$rootScope
.
pageContext
.
appId
,
ConfigService
.
update_item
(
$rootScope
.
pageContext
.
appId
,
cluster
.
env
,
cluster
.
env
,
cluster
.
name
,
cluster
.
name
,
toOperationNamespaceName
,
toOperationNamespace
.
namespace
.
namespace
Name
,
$scope
.
item
).
then
(
$scope
.
item
).
then
(
function
(
result
)
{
function
(
result
)
{
toastr
.
success
(
"更新成功, 如需生效请发布"
);
toastr
.
success
(
"更新成功, 如需生效请发布"
);
...
...
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