Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apollo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
apollo
Commits
5d155623
Unverified
Commit
5d155623
authored
Jan 05, 2019
by
Jason Song
Committed by
GitHub
Jan 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1833 from kezhenxu94/style/cleanup
style: using XxxMapping shortcut
parents
6d323ebd
37c3ba47
Changes
43
Hide whitespace changes
Inline
Side-by-side
Showing
43 changed files
with
353 additions
and
386 deletions
+353
-386
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
...amework/apollo/adminservice/controller/AppController.java
+10
-9
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
...pollo/adminservice/controller/AppNamespaceController.java
+8
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
...ork/apollo/adminservice/controller/ClusterController.java
+8
-8
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
...work/apollo/adminservice/controller/CommitController.java
+2
-4
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/IndexController.java
...ework/apollo/adminservice/controller/IndexController.java
+2
-2
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java
...llo/adminservice/controller/InstanceConfigController.java
+11
-13
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
...mework/apollo/adminservice/controller/ItemController.java
+10
-9
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetController.java
...ork/apollo/adminservice/controller/ItemSetController.java
+2
-4
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceBranchController.java
...lo/adminservice/controller/NamespaceBranchController.java
+9
-9
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
...k/apollo/adminservice/controller/NamespaceController.java
+10
-11
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
...ollo/adminservice/controller/NamespaceLockController.java
+2
-4
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseController.java
...ork/apollo/adminservice/controller/ReleaseController.java
+13
-14
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseHistoryController.java
...llo/adminservice/controller/ReleaseHistoryController.java
+6
-10
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigController.java
...ork/apollo/configservice/controller/ConfigController.java
+16
-18
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileController.java
...apollo/configservice/controller/ConfigFileController.java
+15
-18
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationController.java
...ollo/configservice/controller/NotificationController.java
+8
-10
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
...lo/configservice/controller/NotificationControllerV2.java
+13
-15
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java
...framework/apollo/openapi/v1/controller/AppController.java
+2
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java
...ramework/apollo/openapi/v1/controller/ItemController.java
+9
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java
...ollo/openapi/v1/controller/NamespaceBranchController.java
+5
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java
...ork/apollo/openapi/v1/controller/NamespaceController.java
+7
-9
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java
...ework/apollo/openapi/v1/controller/ReleaseController.java
+7
-9
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
...rip/framework/apollo/portal/controller/AppController.java
+20
-18
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java
...framework/apollo/portal/controller/ClusterController.java
+6
-6
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java
.../framework/apollo/portal/controller/CommitController.java
+3
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java
...ork/apollo/portal/controller/ConfigsExportController.java
+11
-10
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java
...ramework/apollo/portal/controller/ConsumerController.java
+12
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java
...rip/framework/apollo/portal/controller/EnvController.java
+2
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java
...ramework/apollo/portal/controller/FavoriteController.java
+8
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java
...ramework/apollo/portal/controller/InstanceController.java
+6
-9
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
...ip/framework/apollo/portal/controller/ItemController.java
+12
-13
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java
...k/apollo/portal/controller/NamespaceBranchController.java
+11
-10
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+23
-22
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java
...ork/apollo/portal/controller/NamespaceLockController.java
+3
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java
...ework/apollo/portal/controller/PageSettingController.java
+2
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java
...mework/apollo/portal/controller/PermissionController.java
+22
-23
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java
...framework/apollo/portal/controller/ReleaseController.java
+11
-12
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java
...rk/apollo/portal/controller/ReleaseHistoryController.java
+3
-6
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
...work/apollo/portal/controller/ServerConfigController.java
+4
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java
.../framework/apollo/portal/controller/SignInController.java
+2
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java
...work/apollo/portal/controller/SsoHeartbeatController.java
+2
-3
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java
...mework/apollo/portal/controller/SystemInfoController.java
+6
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
...ramework/apollo/portal/controller/UserInfoController.java
+9
-11
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
View file @
5d155623
...
@@ -9,13 +9,14 @@ import com.ctrip.framework.apollo.common.exception.NotFoundException;
...
@@ -9,13 +9,14 @@ import com.ctrip.framework.apollo.common.exception.NotFoundException;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -31,7 +32,7 @@ public class AppController {
...
@@ -31,7 +32,7 @@ public class AppController {
@Autowired
@Autowired
private
AdminService
adminService
;
private
AdminService
adminService
;
@
RequestMapping
(
path
=
"/apps"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps"
)
public
AppDTO
create
(
@RequestBody
AppDTO
dto
)
{
public
AppDTO
create
(
@RequestBody
AppDTO
dto
)
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getAppId
()))
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getAppId
()))
{
throw
new
BadRequestException
(
String
.
format
(
"AppId格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
throw
new
BadRequestException
(
String
.
format
(
"AppId格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
...
@@ -48,7 +49,7 @@ public class AppController {
...
@@ -48,7 +49,7 @@ public class AppController {
return
dto
;
return
dto
;
}
}
@
RequestMapping
(
value
=
"/apps/{appId:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId:.+}"
)
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestParam
String
operator
)
{
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestParam
String
operator
)
{
App
entity
=
appService
.
findOne
(
appId
);
App
entity
=
appService
.
findOne
(
appId
);
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
...
@@ -57,7 +58,7 @@ public class AppController {
...
@@ -57,7 +58,7 @@ public class AppController {
adminService
.
deleteApp
(
entity
,
operator
);
adminService
.
deleteApp
(
entity
,
operator
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId:.+}"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/apps/{appId:.+}"
)
public
void
update
(
@PathVariable
String
appId
,
@RequestBody
App
app
)
{
public
void
update
(
@PathVariable
String
appId
,
@RequestBody
App
app
)
{
if
(!
Objects
.
equals
(
appId
,
app
.
getAppId
()))
{
if
(!
Objects
.
equals
(
appId
,
app
.
getAppId
()))
{
throw
new
BadRequestException
(
"The App Id of path variable and request body is different"
);
throw
new
BadRequestException
(
"The App Id of path variable and request body is different"
);
...
@@ -66,7 +67,7 @@ public class AppController {
...
@@ -66,7 +67,7 @@ public class AppController {
appService
.
update
(
app
);
appService
.
update
(
app
);
}
}
@
RequestMapping
(
value
=
"/apps"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps"
)
public
List
<
AppDTO
>
find
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
,
public
List
<
AppDTO
>
find
(
@RequestParam
(
value
=
"name"
,
required
=
false
)
String
name
,
Pageable
pageable
)
{
Pageable
pageable
)
{
List
<
App
>
app
=
null
;
List
<
App
>
app
=
null
;
...
@@ -78,7 +79,7 @@ public class AppController {
...
@@ -78,7 +79,7 @@ public class AppController {
return
BeanUtils
.
batchTransform
(
AppDTO
.
class
,
app
);
return
BeanUtils
.
batchTransform
(
AppDTO
.
class
,
app
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId:.+}"
)
public
AppDTO
get
(
@PathVariable
(
"appId"
)
String
appId
)
{
public
AppDTO
get
(
@PathVariable
(
"appId"
)
String
appId
)
{
App
app
=
appService
.
findOne
(
appId
);
App
app
=
appService
.
findOne
(
appId
);
if
(
app
==
null
)
{
if
(
app
==
null
)
{
...
@@ -87,7 +88,7 @@ public class AppController {
...
@@ -87,7 +88,7 @@ public class AppController {
return
BeanUtils
.
transform
(
AppDTO
.
class
,
app
);
return
BeanUtils
.
transform
(
AppDTO
.
class
,
app
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/unique"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/unique"
)
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
)
{
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
)
{
return
appService
.
isAppIdUnique
(
appId
);
return
appService
.
isAppIdUnique
(
appId
);
}
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
View file @
5d155623
...
@@ -10,13 +10,13 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
...
@@ -10,13 +10,13 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -30,7 +30,7 @@ public class AppNamespaceController {
...
@@ -30,7 +30,7 @@ public class AppNamespaceController {
@Autowired
@Autowired
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/appnamespaces"
)
public
AppNamespaceDTO
create
(
@RequestBody
AppNamespaceDTO
appNamespace
,
public
AppNamespaceDTO
create
(
@RequestBody
AppNamespaceDTO
appNamespace
,
@RequestParam
(
defaultValue
=
"false"
)
boolean
silentCreation
)
{
@RequestParam
(
defaultValue
=
"false"
)
boolean
silentCreation
)
{
...
@@ -55,7 +55,7 @@ public class AppNamespaceController {
...
@@ -55,7 +55,7 @@ public class AppNamespaceController {
return
BeanUtils
.
transform
(
AppNamespaceDTO
.
class
,
entity
);
return
BeanUtils
.
transform
(
AppNamespaceDTO
.
class
,
entity
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
)
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
String
operator
)
{
@RequestParam
String
operator
)
{
AppNamespace
entity
=
appNamespaceService
.
findOne
(
appId
,
namespaceName
);
AppNamespace
entity
=
appNamespaceService
.
findOne
(
appId
,
namespaceName
);
...
@@ -65,7 +65,7 @@ public class AppNamespaceController {
...
@@ -65,7 +65,7 @@ public class AppNamespaceController {
appNamespaceService
.
deleteAppNamespace
(
entity
,
operator
);
appNamespaceService
.
deleteAppNamespace
(
entity
,
operator
);
}
}
@
RequestMapping
(
value
=
"/appnamespaces/{publicNamespaceName}/namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/appnamespaces/{publicNamespaceName}/namespaces"
)
public
List
<
NamespaceDTO
>
findPublicAppNamespaceAllNamespaces
(
@PathVariable
String
publicNamespaceName
,
Pageable
pageable
)
{
public
List
<
NamespaceDTO
>
findPublicAppNamespaceAllNamespaces
(
@PathVariable
String
publicNamespaceName
,
Pageable
pageable
)
{
List
<
Namespace
>
namespaces
=
namespaceService
.
findPublicAppNamespaceAllNamespaces
(
publicNamespaceName
,
pageable
);
List
<
Namespace
>
namespaces
=
namespaceService
.
findPublicAppNamespaceAllNamespaces
(
publicNamespaceName
,
pageable
);
...
@@ -73,12 +73,12 @@ public class AppNamespaceController {
...
@@ -73,12 +73,12 @@ public class AppNamespaceController {
return
BeanUtils
.
batchTransform
(
NamespaceDTO
.
class
,
namespaces
);
return
BeanUtils
.
batchTransform
(
NamespaceDTO
.
class
,
namespaces
);
}
}
@
RequestMapping
(
value
=
"/appnamespaces/{publicNamespaceName}/associated-namespaces/count"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/appnamespaces/{publicNamespaceName}/associated-namespaces/count"
)
public
int
countPublicAppNamespaceAssociatedNamespaces
(
@PathVariable
String
publicNamespaceName
)
{
public
int
countPublicAppNamespaceAssociatedNamespaces
(
@PathVariable
String
publicNamespaceName
)
{
return
namespaceService
.
countPublicAppNamespaceAssociatedNamespaces
(
publicNamespaceName
);
return
namespaceService
.
countPublicAppNamespaceAssociatedNamespaces
(
publicNamespaceName
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/appnamespaces"
)
public
List
<
AppNamespaceDTO
>
getAppNamespaces
(
@PathVariable
(
"appId"
)
String
appId
)
{
public
List
<
AppNamespaceDTO
>
getAppNamespaces
(
@PathVariable
(
"appId"
)
String
appId
)
{
List
<
AppNamespace
>
appNamespaces
=
appNamespaceService
.
findByAppId
(
appId
);
List
<
AppNamespace
>
appNamespaces
=
appNamespaceService
.
findByAppId
(
appId
);
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
View file @
5d155623
...
@@ -7,13 +7,13 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
...
@@ -7,13 +7,13 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -25,7 +25,7 @@ public class ClusterController {
...
@@ -25,7 +25,7 @@ public class ClusterController {
@Autowired
@Autowired
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@
RequestMapping
(
path
=
"/apps/{appId}/clusters"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters"
)
public
ClusterDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
public
ClusterDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestParam
(
value
=
"autoCreatePrivateNamespace"
,
defaultValue
=
"true"
)
boolean
autoCreatePrivateNamespace
,
@RequestParam
(
value
=
"autoCreatePrivateNamespace"
,
defaultValue
=
"true"
)
boolean
autoCreatePrivateNamespace
,
@RequestBody
ClusterDTO
dto
)
{
@RequestBody
ClusterDTO
dto
)
{
...
@@ -49,7 +49,7 @@ public class ClusterController {
...
@@ -49,7 +49,7 @@ public class ClusterController {
return
dto
;
return
dto
;
}
}
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/clusters/{clusterName:.+}"
)
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@RequestParam
String
operator
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
,
@RequestParam
String
operator
)
{
...
@@ -66,13 +66,13 @@ public class ClusterController {
...
@@ -66,13 +66,13 @@ public class ClusterController {
clusterService
.
delete
(
entity
.
getId
(),
operator
);
clusterService
.
delete
(
entity
.
getId
(),
operator
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters"
)
public
List
<
ClusterDTO
>
find
(
@PathVariable
(
"appId"
)
String
appId
)
{
public
List
<
ClusterDTO
>
find
(
@PathVariable
(
"appId"
)
String
appId
)
{
List
<
Cluster
>
clusters
=
clusterService
.
findParentClusters
(
appId
);
List
<
Cluster
>
clusters
=
clusterService
.
findParentClusters
(
appId
);
return
BeanUtils
.
batchTransform
(
ClusterDTO
.
class
,
clusters
);
return
BeanUtils
.
batchTransform
(
ClusterDTO
.
class
,
clusters
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName:.+}"
)
public
ClusterDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
public
ClusterDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
Cluster
cluster
=
clusterService
.
findOne
(
appId
,
clusterName
);
Cluster
cluster
=
clusterService
.
findOne
(
appId
,
clusterName
);
...
@@ -82,7 +82,7 @@ public class ClusterController {
...
@@ -82,7 +82,7 @@ public class ClusterController {
return
BeanUtils
.
transform
(
ClusterDTO
.
class
,
cluster
);
return
BeanUtils
.
transform
(
ClusterDTO
.
class
,
cluster
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/cluster/{clusterName}/unique"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/cluster/{clusterName}/unique"
)
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
,
public
boolean
isAppIdUnique
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
return
clusterService
.
isClusterNameUnique
(
appId
,
clusterName
);
return
clusterService
.
isClusterNameUnique
(
appId
,
clusterName
);
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/CommitController.java
View file @
5d155623
...
@@ -4,12 +4,10 @@ import com.ctrip.framework.apollo.biz.entity.Commit;
...
@@ -4,12 +4,10 @@ import com.ctrip.framework.apollo.biz.entity.Commit;
import
com.ctrip.framework.apollo.biz.service.CommitService
;
import
com.ctrip.framework.apollo.biz.service.CommitService
;
import
com.ctrip.framework.apollo.common.dto.CommitDTO
;
import
com.ctrip.framework.apollo.common.dto.CommitDTO
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.List
;
...
@@ -21,7 +19,7 @@ public class CommitController {
...
@@ -21,7 +19,7 @@ public class CommitController {
@Autowired
@Autowired
private
CommitService
commitService
;
private
CommitService
commitService
;
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/commit"
)
public
List
<
CommitDTO
>
find
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
List
<
CommitDTO
>
find
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
Pageable
pageable
){
@PathVariable
String
namespaceName
,
Pageable
pageable
){
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/IndexController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
@RequestMapping
(
path
=
"/"
)
@RequestMapping
(
path
=
"/"
)
public
class
IndexController
{
public
class
IndexController
{
@
RequestMapping
(
path
=
""
,
method
=
RequestMethod
.
GET
)
@
GetMapping
public
String
index
()
{
public
String
index
()
{
return
"apollo-adminservice"
;
return
"apollo-adminservice"
;
}
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/InstanceConfigController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Sets
;
import
com.ctrip.framework.apollo.biz.entity.Instance
;
import
com.ctrip.framework.apollo.biz.entity.Instance
;
import
com.ctrip.framework.apollo.biz.entity.InstanceConfig
;
import
com.ctrip.framework.apollo.biz.entity.InstanceConfig
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
...
@@ -18,14 +11,19 @@ import com.ctrip.framework.apollo.common.dto.PageDTO;
...
@@ -18,14 +11,19 @@ import com.ctrip.framework.apollo.common.dto.PageDTO;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Sets
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -49,7 +47,7 @@ public class InstanceConfigController {
...
@@ -49,7 +47,7 @@ public class InstanceConfigController {
@Autowired
@Autowired
private
InstanceService
instanceService
;
private
InstanceService
instanceService
;
@
RequestMapping
(
value
=
"/by-release"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/by-release"
)
public
PageDTO
<
InstanceDTO
>
getByRelease
(
@RequestParam
(
"releaseId"
)
long
releaseId
,
public
PageDTO
<
InstanceDTO
>
getByRelease
(
@RequestParam
(
"releaseId"
)
long
releaseId
,
Pageable
pageable
)
{
Pageable
pageable
)
{
Release
release
=
releaseService
.
findOne
(
releaseId
);
Release
release
=
releaseService
.
findOne
(
releaseId
);
...
@@ -96,7 +94,7 @@ public class InstanceConfigController {
...
@@ -96,7 +94,7 @@ public class InstanceConfigController {
return
new
PageDTO
<>(
instanceDTOs
,
pageable
,
instanceConfigsPage
.
getTotalElements
());
return
new
PageDTO
<>(
instanceDTOs
,
pageable
,
instanceConfigsPage
.
getTotalElements
());
}
}
@
RequestMapping
(
value
=
"/by-namespace-and-releases-not-in"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/by-namespace-and-releases-not-in"
)
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
@RequestParam
(
"appId"
)
String
appId
,
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
@RequestParam
(
"appId"
)
String
appId
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
,
...
@@ -159,7 +157,7 @@ public class InstanceConfigController {
...
@@ -159,7 +157,7 @@ public class InstanceConfigController {
return
instanceDTOs
;
return
instanceDTOs
;
}
}
@
RequestMapping
(
value
=
"/by-namespace"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/by-namespace"
)
public
PageDTO
<
InstanceDTO
>
getInstancesByNamespace
(
public
PageDTO
<
InstanceDTO
>
getInstancesByNamespace
(
@RequestParam
(
"appId"
)
String
appId
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"appId"
)
String
appId
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
,
...
@@ -178,7 +176,7 @@ public class InstanceConfigController {
...
@@ -178,7 +176,7 @@ public class InstanceConfigController {
return
new
PageDTO
<>(
instanceDTOs
,
pageable
,
instances
.
getTotalElements
());
return
new
PageDTO
<>(
instanceDTOs
,
pageable
,
instances
.
getTotalElements
());
}
}
@
RequestMapping
(
value
=
"/by-namespace/count"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/by-namespace/count"
)
public
long
getInstancesCountByNamespace
(
@RequestParam
(
"appId"
)
String
appId
,
public
long
getInstancesCountByNamespace
(
@RequestParam
(
"appId"
)
String
appId
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"clusterName"
)
String
clusterName
,
@RequestParam
(
"namespaceName"
)
String
namespaceName
)
{
@RequestParam
(
"namespaceName"
)
String
namespaceName
)
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemController.java
View file @
5d155623
...
@@ -12,12 +12,13 @@ import com.ctrip.framework.apollo.common.dto.ItemDTO;
...
@@ -12,12 +12,13 @@ import com.ctrip.framework.apollo.common.dto.ItemDTO;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -34,7 +35,7 @@ public class ItemController {
...
@@ -34,7 +35,7 @@ public class ItemController {
private
CommitService
commitService
;
private
CommitService
commitService
;
@PreAcquireNamespaceLock
@PreAcquireNamespaceLock
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
)
public
ItemDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
public
ItemDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestBody
ItemDTO
dto
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestBody
ItemDTO
dto
)
{
...
@@ -63,7 +64,7 @@ public class ItemController {
...
@@ -63,7 +64,7 @@ public class ItemController {
}
}
@PreAcquireNamespaceLock
@PreAcquireNamespaceLock
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
)
public
ItemDTO
update
(
@PathVariable
(
"appId"
)
String
appId
,
public
ItemDTO
update
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -105,7 +106,7 @@ public class ItemController {
...
@@ -105,7 +106,7 @@ public class ItemController {
}
}
@PreAcquireNamespaceLock
@PreAcquireNamespaceLock
@
RequestMapping
(
path
=
"/items/{itemId}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/items/{itemId}"
)
public
void
delete
(
@PathVariable
(
"itemId"
)
long
itemId
,
@RequestParam
String
operator
)
{
public
void
delete
(
@PathVariable
(
"itemId"
)
long
itemId
,
@RequestParam
String
operator
)
{
Item
entity
=
itemService
.
findOne
(
itemId
);
Item
entity
=
itemService
.
findOne
(
itemId
);
if
(
entity
==
null
)
{
if
(
entity
==
null
)
{
...
@@ -125,14 +126,14 @@ public class ItemController {
...
@@ -125,14 +126,14 @@ public class ItemController {
commitService
.
save
(
commit
);
commitService
.
save
(
commit
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
)
public
List
<
ItemDTO
>
findItems
(
@PathVariable
(
"appId"
)
String
appId
,
public
List
<
ItemDTO
>
findItems
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
return
BeanUtils
.
batchTransform
(
ItemDTO
.
class
,
itemService
.
findItemsWithOrdered
(
appId
,
clusterName
,
namespaceName
));
return
BeanUtils
.
batchTransform
(
ItemDTO
.
class
,
itemService
.
findItemsWithOrdered
(
appId
,
clusterName
,
namespaceName
));
}
}
@
RequestMapping
(
value
=
"/items/{itemId}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/items/{itemId}"
)
public
ItemDTO
get
(
@PathVariable
(
"itemId"
)
long
itemId
)
{
public
ItemDTO
get
(
@PathVariable
(
"itemId"
)
long
itemId
)
{
Item
item
=
itemService
.
findOne
(
itemId
);
Item
item
=
itemService
.
findOne
(
itemId
);
if
(
item
==
null
)
{
if
(
item
==
null
)
{
...
@@ -141,7 +142,7 @@ public class ItemController {
...
@@ -141,7 +142,7 @@ public class ItemController {
return
BeanUtils
.
transform
(
ItemDTO
.
class
,
item
);
return
BeanUtils
.
transform
(
ItemDTO
.
class
,
item
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
)
public
ItemDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
public
ItemDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"key"
)
String
key
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"key"
)
String
key
)
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ItemSetController.java
View file @
5d155623
...
@@ -3,14 +3,12 @@ package com.ctrip.framework.apollo.adminservice.controller;
...
@@ -3,14 +3,12 @@ package com.ctrip.framework.apollo.adminservice.controller;
import
com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock
;
import
com.ctrip.framework.apollo.adminservice.aop.PreAcquireNamespaceLock
;
import
com.ctrip.framework.apollo.biz.service.ItemSetService
;
import
com.ctrip.framework.apollo.biz.service.ItemSetService
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.common.dto.ItemChangeSets
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -20,7 +18,7 @@ public class ItemSetController {
...
@@ -20,7 +18,7 @@ public class ItemSetController {
private
ItemSetService
itemSetService
;
private
ItemSetService
itemSetService
;
@PreAcquireNamespaceLock
@PreAcquireNamespaceLock
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/itemset"
)
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
ItemChangeSets
changeSet
)
{
@PathVariable
String
namespaceName
,
@RequestBody
ItemChangeSets
changeSet
)
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceBranchController.java
View file @
5d155623
...
@@ -13,13 +13,14 @@ import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
...
@@ -13,13 +13,14 @@ import com.ctrip.framework.apollo.common.dto.NamespaceDTO;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.GrayReleaseRuleItemTransformer
;
import
com.ctrip.framework.apollo.common.utils.GrayReleaseRuleItemTransformer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -34,7 +35,7 @@ public class NamespaceBranchController {
...
@@ -34,7 +35,7 @@ public class NamespaceBranchController {
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceDTO
createBranch
(
@PathVariable
String
appId
,
public
NamespaceDTO
createBranch
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -47,8 +48,7 @@ public class NamespaceBranchController {
...
@@ -47,8 +48,7 @@ public class NamespaceBranchController {
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
createdBranch
);
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
createdBranch
);
}
}
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
@GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
method
=
RequestMethod
.
GET
)
public
GrayReleaseRuleDTO
findBranchGrayRules
(
@PathVariable
String
appId
,
public
GrayReleaseRuleDTO
findBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -72,7 +72,7 @@ public class NamespaceBranchController {
...
@@ -72,7 +72,7 @@ public class NamespaceBranchController {
}
}
@Transactional
@Transactional
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
public
void
updateBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
void
updateBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestBody
GrayReleaseRuleDTO
newRuleDto
)
{
@RequestBody
GrayReleaseRuleDTO
newRuleDto
)
{
...
@@ -90,7 +90,7 @@ public class NamespaceBranchController {
...
@@ -90,7 +90,7 @@ public class NamespaceBranchController {
}
}
@Transactional
@Transactional
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
)
public
void
deleteBranch
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
void
deleteBranch
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestParam
(
"operator"
)
String
operator
)
{
@RequestParam
(
"operator"
)
String
operator
)
{
...
@@ -105,7 +105,7 @@ public class NamespaceBranchController {
...
@@ -105,7 +105,7 @@ public class NamespaceBranchController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceDTO
loadNamespaceBranch
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
NamespaceDTO
loadNamespaceBranch
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
namespaceName
)
{
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
View file @
5d155623
...
@@ -7,12 +7,12 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
...
@@ -7,12 +7,12 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -25,7 +25,7 @@ public class NamespaceController {
...
@@ -25,7 +25,7 @@ public class NamespaceController {
@Autowired
@Autowired
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces"
)
public
NamespaceDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
public
NamespaceDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@RequestBody
NamespaceDTO
dto
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
,
@RequestBody
NamespaceDTO
dto
)
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getNamespaceName
()))
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getNamespaceName
()))
{
...
@@ -43,7 +43,7 @@ public class NamespaceController {
...
@@ -43,7 +43,7 @@ public class NamespaceController {
return
dto
;
return
dto
;
}
}
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
String
operator
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@RequestParam
String
operator
)
{
...
@@ -54,14 +54,14 @@ public class NamespaceController {
...
@@ -54,14 +54,14 @@ public class NamespaceController {
namespaceService
.
deleteNamespace
(
entity
,
operator
);
namespaceService
.
deleteNamespace
(
entity
,
operator
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces"
)
public
List
<
NamespaceDTO
>
find
(
@PathVariable
(
"appId"
)
String
appId
,
public
List
<
NamespaceDTO
>
find
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
List
<
Namespace
>
groups
=
namespaceService
.
findNamespaces
(
appId
,
clusterName
);
List
<
Namespace
>
groups
=
namespaceService
.
findNamespaces
(
appId
,
clusterName
);
return
BeanUtils
.
batchTransform
(
NamespaceDTO
.
class
,
groups
);
return
BeanUtils
.
batchTransform
(
NamespaceDTO
.
class
,
groups
);
}
}
@
RequestMapping
(
value
=
"/namespaces/{namespaceId}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/namespaces/{namespaceId}"
)
public
NamespaceDTO
get
(
@PathVariable
(
"namespaceId"
)
Long
namespaceId
)
{
public
NamespaceDTO
get
(
@PathVariable
(
"namespaceId"
)
Long
namespaceId
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
namespaceId
);
Namespace
namespace
=
namespaceService
.
findOne
(
namespaceId
);
if
(
namespace
==
null
)
if
(
namespace
==
null
)
...
@@ -69,7 +69,7 @@ public class NamespaceController {
...
@@ -69,7 +69,7 @@ public class NamespaceController {
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
namespace
);
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
namespace
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
NamespaceDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
public
NamespaceDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
...
@@ -79,8 +79,7 @@ public class NamespaceController {
...
@@ -79,8 +79,7 @@ public class NamespaceController {
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
namespace
);
return
BeanUtils
.
transform
(
NamespaceDTO
.
class
,
namespace
);
}
}
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
,
@GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
)
method
=
RequestMethod
.
GET
)
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
appId
,
public
NamespaceDTO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
namespaceName
)
{
...
@@ -96,7 +95,7 @@ public class NamespaceController {
...
@@ -96,7 +95,7 @@ public class NamespaceController {
/**
/**
* cluster -> cluster has not published namespaces?
* cluster -> cluster has not published namespaces?
*/
*/
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/publish_info"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/namespaces/publish_info"
)
public
Map
<
String
,
Boolean
>
namespacePublishInfo
(
@PathVariable
String
appId
)
{
public
Map
<
String
,
Boolean
>
namespacePublishInfo
(
@PathVariable
String
appId
)
{
return
namespaceService
.
namespacePublishInfo
(
appId
);
return
namespaceService
.
namespacePublishInfo
(
appId
);
}
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceLockController.java
View file @
5d155623
...
@@ -8,11 +8,9 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService;
...
@@ -8,11 +8,9 @@ import com.ctrip.framework.apollo.biz.service.NamespaceService;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceLockDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -26,7 +24,7 @@ public class NamespaceLockController {
...
@@ -26,7 +24,7 @@ public class NamespaceLockController {
@Autowired
@Autowired
private
BizConfig
bizConfig
;
private
BizConfig
bizConfig
;
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
NamespaceLockDTO
getNamespaceLockOwner
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
NamespaceLockDTO
getNamespaceLockOwner
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
Namespace
namespace
=
namespaceService
.
findOne
(
appId
,
clusterName
,
namespaceName
);
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.google.common.base.Splitter
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Namespace
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.message.MessageSender
;
import
com.ctrip.framework.apollo.biz.message.MessageSender
;
...
@@ -16,14 +14,15 @@ import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
...
@@ -16,14 +14,15 @@ import com.ctrip.framework.apollo.common.dto.ItemChangeSets;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.exception.NotFoundException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.google.common.base.Splitter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -48,7 +47,7 @@ public class ReleaseController {
...
@@ -48,7 +47,7 @@ public class ReleaseController {
private
NamespaceBranchService
namespaceBranchService
;
private
NamespaceBranchService
namespaceBranchService
;
@
RequestMapping
(
value
=
"/releases/{releaseId}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/releases/{releaseId}"
)
public
ReleaseDTO
get
(
@PathVariable
(
"releaseId"
)
long
releaseId
)
{
public
ReleaseDTO
get
(
@PathVariable
(
"releaseId"
)
long
releaseId
)
{
Release
release
=
releaseService
.
findOne
(
releaseId
);
Release
release
=
releaseService
.
findOne
(
releaseId
);
if
(
release
==
null
)
{
if
(
release
==
null
)
{
...
@@ -57,7 +56,7 @@ public class ReleaseController {
...
@@ -57,7 +56,7 @@ public class ReleaseController {
return
BeanUtils
.
transform
(
ReleaseDTO
.
class
,
release
);
return
BeanUtils
.
transform
(
ReleaseDTO
.
class
,
release
);
}
}
@
RequestMapping
(
value
=
"/releases"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/releases"
)
public
List
<
ReleaseDTO
>
findReleaseByIds
(
@RequestParam
(
"releaseIds"
)
String
releaseIds
)
{
public
List
<
ReleaseDTO
>
findReleaseByIds
(
@RequestParam
(
"releaseIds"
)
String
releaseIds
)
{
Set
<
Long
>
releaseIdSet
=
RELEASES_SPLITTER
.
splitToList
(
releaseIds
).
stream
().
map
(
Long:
:
parseLong
)
Set
<
Long
>
releaseIdSet
=
RELEASES_SPLITTER
.
splitToList
(
releaseIds
).
stream
().
map
(
Long:
:
parseLong
)
.
collect
(
Collectors
.
toSet
());
.
collect
(
Collectors
.
toSet
());
...
@@ -67,7 +66,7 @@ public class ReleaseController {
...
@@ -67,7 +66,7 @@ public class ReleaseController {
return
BeanUtils
.
batchTransform
(
ReleaseDTO
.
class
,
releases
);
return
BeanUtils
.
batchTransform
(
ReleaseDTO
.
class
,
releases
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
)
public
List
<
ReleaseDTO
>
findAllReleases
(
@PathVariable
(
"appId"
)
String
appId
,
public
List
<
ReleaseDTO
>
findAllReleases
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -77,7 +76,7 @@ public class ReleaseController {
...
@@ -77,7 +76,7 @@ public class ReleaseController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active"
)
public
List
<
ReleaseDTO
>
findActiveReleases
(
@PathVariable
(
"appId"
)
String
appId
,
public
List
<
ReleaseDTO
>
findActiveReleases
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -86,7 +85,7 @@ public class ReleaseController {
...
@@ -86,7 +85,7 @@ public class ReleaseController {
return
BeanUtils
.
batchTransform
(
ReleaseDTO
.
class
,
releases
);
return
BeanUtils
.
batchTransform
(
ReleaseDTO
.
class
,
releases
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
)
public
ReleaseDTO
getLatest
(
@PathVariable
(
"appId"
)
String
appId
,
public
ReleaseDTO
getLatest
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
@PathVariable
(
"namespaceName"
)
String
namespaceName
)
{
...
@@ -95,7 +94,7 @@ public class ReleaseController {
...
@@ -95,7 +94,7 @@ public class ReleaseController {
}
}
@Transactional
@Transactional
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
)
public
ReleaseDTO
publish
(
@PathVariable
(
"appId"
)
String
appId
,
public
ReleaseDTO
publish
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -130,7 +129,7 @@ public class ReleaseController {
...
@@ -130,7 +129,7 @@ public class ReleaseController {
* @return published result
* @return published result
*/
*/
@Transactional
@Transactional
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/updateAndPublish"
)
public
ReleaseDTO
updateAndPublish
(
@PathVariable
(
"appId"
)
String
appId
,
public
ReleaseDTO
updateAndPublish
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -162,7 +161,7 @@ public class ReleaseController {
...
@@ -162,7 +161,7 @@ public class ReleaseController {
}
}
@Transactional
@Transactional
@
RequestMapping
(
path
=
"/releases/{releaseId}/rollback"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/releases/{releaseId}/rollback"
)
public
void
rollback
(
@PathVariable
(
"releaseId"
)
long
releaseId
,
public
void
rollback
(
@PathVariable
(
"releaseId"
)
long
releaseId
,
@RequestParam
(
"operator"
)
String
operator
)
{
@RequestParam
(
"operator"
)
String
operator
)
{
...
@@ -177,7 +176,7 @@ public class ReleaseController {
...
@@ -177,7 +176,7 @@ public class ReleaseController {
}
}
@Transactional
@Transactional
@
RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/gray-del-releases"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/gray-del-releases"
)
public
ReleaseDTO
publish
(
@PathVariable
(
"appId"
)
String
appId
,
public
ReleaseDTO
publish
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ReleaseHistoryController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
adminservice
.
controller
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseHistory
;
import
com.ctrip.framework.apollo.biz.service.ReleaseHistoryService
;
import
com.ctrip.framework.apollo.biz.service.ReleaseHistoryService
;
import
com.ctrip.framework.apollo.common.dto.PageDTO
;
import
com.ctrip.framework.apollo.common.dto.PageDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseHistoryDTO
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -36,8 +33,7 @@ public class ReleaseHistoryController {
...
@@ -36,8 +33,7 @@ public class ReleaseHistoryController {
@Autowired
@Autowired
private
ReleaseHistoryService
releaseHistoryService
;
private
ReleaseHistoryService
releaseHistoryService
;
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories"
,
@GetMapping
(
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories"
)
method
=
RequestMethod
.
GET
)
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -49,7 +45,7 @@ public class ReleaseHistoryController {
...
@@ -49,7 +45,7 @@ public class ReleaseHistoryController {
}
}
@
RequestMapping
(
value
=
"/releases/histories/by_release_id_and_operation"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/releases/histories/by_release_id_and_operation"
)
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoryByReleaseIdAndOperation
(
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoryByReleaseIdAndOperation
(
@RequestParam
(
"releaseId"
)
long
releaseId
,
@RequestParam
(
"releaseId"
)
long
releaseId
,
@RequestParam
(
"operation"
)
int
operation
,
@RequestParam
(
"operation"
)
int
operation
,
...
@@ -60,7 +56,7 @@ public class ReleaseHistoryController {
...
@@ -60,7 +56,7 @@ public class ReleaseHistoryController {
return
transform2PageDTO
(
result
,
pageable
);
return
transform2PageDTO
(
result
,
pageable
);
}
}
@
RequestMapping
(
value
=
"/releases/histories/by_previous_release_id_and_operation"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/releases/histories/by_previous_release_id_and_operation"
)
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoryByPreviousReleaseIdAndOperation
(
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoryByPreviousReleaseIdAndOperation
(
@RequestParam
(
"previousReleaseId"
)
long
previousReleaseId
,
@RequestParam
(
"previousReleaseId"
)
long
previousReleaseId
,
@RequestParam
(
"operation"
)
int
operation
,
@RequestParam
(
"operation"
)
int
operation
,
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
import
java.io.IOException
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.biz.entity.Release
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.configservice.service.AppNamespaceServiceWithCache
;
import
com.ctrip.framework.apollo.configservice.service.AppNamespaceServiceWithCache
;
...
@@ -33,6 +16,21 @@ import com.google.common.collect.Lists;
...
@@ -33,6 +16,21 @@ import com.google.common.collect.Lists;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Maps
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.google.gson.reflect.TypeToken
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.lang.reflect.Type
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
/**
/**
* @author Jason Song(song_s@ctrip.com)
* @author Jason Song(song_s@ctrip.com)
...
@@ -56,7 +54,7 @@ public class ConfigController {
...
@@ -56,7 +54,7 @@ public class ConfigController {
private
static
final
Type
configurationTypeReference
=
new
TypeToken
<
Map
<
String
,
String
>>()
{
private
static
final
Type
configurationTypeReference
=
new
TypeToken
<
Map
<
String
,
String
>>()
{
}.
getType
();
}.
getType
();
@
RequestMapping
(
value
=
"/{appId}/{clusterName}/{namespace:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/{appId}/{clusterName}/{namespace:.+}"
)
public
ApolloConfig
queryConfig
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
public
ApolloConfig
queryConfig
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespace
,
@PathVariable
String
namespace
,
@RequestParam
(
value
=
"dataCenter"
,
required
=
false
)
String
dataCenter
,
@RequestParam
(
value
=
"dataCenter"
,
required
=
false
)
String
dataCenter
,
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/ConfigFileController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolder
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
import
com.ctrip.framework.apollo.biz.message.Topics
;
import
com.ctrip.framework.apollo.configservice.util.NamespaceUtil
;
import
com.ctrip.framework.apollo.configservice.util.WatchKeysUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.utils.PropertiesUtil
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
...
@@ -13,30 +23,20 @@ import com.google.common.collect.Lists;
...
@@ -13,30 +23,20 @@ import com.google.common.collect.Lists;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
com.google.common.collect.Multimaps
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.grayReleaseRule.GrayReleaseRulesHolder
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
import
com.ctrip.framework.apollo.biz.message.Topics
;
import
com.ctrip.framework.apollo.configservice.util.NamespaceUtil
;
import
com.ctrip.framework.apollo.configservice.util.WatchKeysUtil
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfig
;
import
com.ctrip.framework.apollo.core.utils.PropertiesUtil
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpHeaders
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -44,9 +44,6 @@ import java.util.Properties;
...
@@ -44,9 +44,6 @@ import java.util.Properties;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
/**
/**
* @author Jason Song(song_s@ctrip.com)
* @author Jason Song(song_s@ctrip.com)
*/
*/
...
@@ -116,7 +113,7 @@ public class ConfigFileController implements ReleaseMessageListener {
...
@@ -116,7 +113,7 @@ public class ConfigFileController implements ReleaseMessageListener {
NOT_FOUND_RESPONSE
=
new
ResponseEntity
<>(
HttpStatus
.
NOT_FOUND
);
NOT_FOUND_RESPONSE
=
new
ResponseEntity
<>(
HttpStatus
.
NOT_FOUND
);
}
}
@
RequestMapping
(
value
=
"/{appId}/{clusterName}/{namespace:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/{appId}/{clusterName}/{namespace:.+}"
)
public
ResponseEntity
<
String
>
queryConfigAsProperties
(
@PathVariable
String
appId
,
public
ResponseEntity
<
String
>
queryConfigAsProperties
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespace
,
@PathVariable
String
namespace
,
...
@@ -137,7 +134,7 @@ public class ConfigFileController implements ReleaseMessageListener {
...
@@ -137,7 +134,7 @@ public class ConfigFileController implements ReleaseMessageListener {
return
new
ResponseEntity
<>(
result
,
propertiesResponseHeaders
,
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
result
,
propertiesResponseHeaders
,
HttpStatus
.
OK
);
}
}
@
RequestMapping
(
value
=
"/json/{appId}/{clusterName}/{namespace:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/json/{appId}/{clusterName}/{namespace:.+}"
)
public
ResponseEntity
<
String
>
queryConfigAsJson
(
@PathVariable
String
appId
,
public
ResponseEntity
<
String
>
queryConfigAsJson
(
@PathVariable
String
appId
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespace
,
@PathVariable
String
namespace
,
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
import
com.ctrip.framework.apollo.biz.message.Topics
;
import
com.ctrip.framework.apollo.biz.message.Topics
;
...
@@ -17,14 +10,19 @@ import com.ctrip.framework.apollo.configservice.util.WatchKeysUtil;
...
@@ -17,14 +10,19 @@ import com.ctrip.framework.apollo.configservice.util.WatchKeysUtil;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.context.request.async.DeferredResult
;
import
org.springframework.web.context.request.async.DeferredResult
;
...
@@ -71,7 +69,7 @@ public class NotificationController implements ReleaseMessageListener {
...
@@ -71,7 +69,7 @@ public class NotificationController implements ReleaseMessageListener {
* @param clientIp the client side ip
* @param clientIp the client side ip
* @return a deferred result
* @return a deferred result
*/
*/
@
RequestMapping
(
method
=
RequestMethod
.
GET
)
@
GetMapping
public
DeferredResult
<
ResponseEntity
<
ApolloConfigNotification
>>
pollNotification
(
public
DeferredResult
<
ResponseEntity
<
ApolloConfigNotification
>>
pollNotification
(
@RequestParam
(
value
=
"appId"
)
String
appId
,
@RequestParam
(
value
=
"appId"
)
String
appId
,
@RequestParam
(
value
=
"cluster"
)
String
cluster
,
@RequestParam
(
value
=
"cluster"
)
String
cluster
,
...
...
apollo-configservice/src/main/java/com/ctrip/framework/apollo/configservice/controller/NotificationControllerV2.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
configservice
.
controller
;
import
com.google.common.base.Function
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
com.google.common.collect.Sets
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.biz.config.BizConfig
;
import
com.ctrip.framework.apollo.biz.config.BizConfig
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.entity.ReleaseMessage
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
import
com.ctrip.framework.apollo.biz.message.ReleaseMessageListener
;
...
@@ -26,14 +14,24 @@ import com.ctrip.framework.apollo.core.ConfigConsts;
...
@@ -26,14 +14,24 @@ import com.ctrip.framework.apollo.core.ConfigConsts;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.dto.ApolloConfigNotification
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.base.Function
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.HashMultimap
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
import
com.google.common.collect.Multimap
;
import
com.google.common.collect.Multimaps
;
import
com.google.common.collect.Sets
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.context.request.async.DeferredResult
;
import
org.springframework.web.context.request.async.DeferredResult
;
...
@@ -88,7 +86,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
...
@@ -88,7 +86,7 @@ public class NotificationControllerV2 implements ReleaseMessageListener {
(
"NotificationControllerV2"
,
true
));
(
"NotificationControllerV2"
,
true
));
}
}
@
RequestMapping
(
method
=
RequestMethod
.
GET
)
@
GetMapping
public
DeferredResult
<
ResponseEntity
<
List
<
ApolloConfigNotification
>>>
pollNotification
(
public
DeferredResult
<
ResponseEntity
<
List
<
ApolloConfigNotification
>>>
pollNotification
(
@RequestParam
(
value
=
"appId"
)
String
appId
,
@RequestParam
(
value
=
"appId"
)
String
appId
,
@RequestParam
(
value
=
"cluster"
)
String
cluster
,
@RequestParam
(
value
=
"cluster"
)
String
cluster
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/AppController.java
View file @
5d155623
...
@@ -6,11 +6,10 @@ import com.ctrip.framework.apollo.core.enums.Env;
...
@@ -6,11 +6,10 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenEnvClusterDTO
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
com.ctrip.framework.apollo.portal.service.ClusterService
;
import
com.ctrip.framework.apollo.portal.service.ClusterService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
@@ -25,7 +24,7 @@ public class AppController {
...
@@ -25,7 +24,7 @@ public class AppController {
@Autowired
@Autowired
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@
RequestMapping
(
value
=
"/apps/{appId}/envclusters"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envclusters"
)
public
List
<
OpenEnvClusterDTO
>
loadEnvClusterInfo
(
@PathVariable
String
appId
){
public
List
<
OpenEnvClusterDTO
>
loadEnvClusterInfo
(
@PathVariable
String
appId
){
List
<
OpenEnvClusterDTO
>
envClusters
=
new
LinkedList
<>();
List
<
OpenEnvClusterDTO
>
envClusters
=
new
LinkedList
<>();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ItemController.java
View file @
5d155623
...
@@ -9,19 +9,21 @@ import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
...
@@ -9,19 +9,21 @@ import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
import
com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils
;
import
com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils
;
import
com.ctrip.framework.apollo.portal.service.ItemService
;
import
com.ctrip.framework.apollo.portal.service.ItemService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.HttpStatusCodeException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.web.client.HttpStatusCodeException
;
@RestController
(
"openapiItemController"
)
@RestController
(
"openapiItemController"
)
...
@@ -33,7 +35,7 @@ public class ItemController {
...
@@ -33,7 +35,7 @@ public class ItemController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
)
public
OpenItemDTO
getItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
public
OpenItemDTO
getItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
key
)
{
@PathVariable
String
namespaceName
,
@PathVariable
String
key
)
{
...
@@ -43,7 +45,7 @@ public class ItemController {
...
@@ -43,7 +45,7 @@ public class ItemController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items"
)
public
OpenItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
OpenItemDTO
item
,
HttpServletRequest
request
)
{
@RequestBody
OpenItemDTO
item
,
HttpServletRequest
request
)
{
...
@@ -71,7 +73,7 @@ public class ItemController {
...
@@ -71,7 +73,7 @@ public class ItemController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
)
public
void
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
key
,
@RequestBody
OpenItemDTO
item
,
@PathVariable
String
key
,
@RequestBody
OpenItemDTO
item
,
...
@@ -112,7 +114,7 @@ public class ItemController {
...
@@ -112,7 +114,7 @@ public class ItemController {
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/items/{key:.+}"
)
public
void
deleteItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
deleteItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
key
,
@RequestParam
String
operator
,
@PathVariable
String
key
,
@RequestParam
String
operator
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceBranchController.java
View file @
5d155623
...
@@ -39,7 +39,7 @@ public class NamespaceBranchController {
...
@@ -39,7 +39,7 @@ public class NamespaceBranchController {
@Autowired
@Autowired
private
UserService
userService
;
private
UserService
userService
;
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
OpenNamespaceDTO
findBranch
(
@PathVariable
String
appId
,
public
OpenNamespaceDTO
findBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -52,7 +52,7 @@ public class NamespaceBranchController {
...
@@ -52,7 +52,7 @@ public class NamespaceBranchController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
OpenNamespaceDTO
createBranch
(
@PathVariable
String
appId
,
public
OpenNamespaceDTO
createBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -73,7 +73,7 @@ public class NamespaceBranchController {
...
@@ -73,7 +73,7 @@ public class NamespaceBranchController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
)
public
void
deleteBranch
(
@PathVariable
String
appId
,
public
void
deleteBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -101,7 +101,7 @@ public class NamespaceBranchController {
...
@@ -101,7 +101,7 @@ public class NamespaceBranchController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
public
OpenGrayReleaseRuleDTO
getBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenGrayReleaseRuleDTO
getBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -114,7 +114,7 @@ public class NamespaceBranchController {
...
@@ -114,7 +114,7 @@ public class NamespaceBranchController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasModifyNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
public
void
updateBranchRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
updateBranchRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestBody
OpenGrayReleaseRuleDTO
rules
,
@PathVariable
String
branchName
,
@RequestBody
OpenGrayReleaseRuleDTO
rules
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java
View file @
5d155623
...
@@ -19,21 +19,19 @@ import com.ctrip.framework.apollo.portal.service.AppNamespaceService;
...
@@ -19,21 +19,19 @@ import com.ctrip.framework.apollo.portal.service.AppNamespaceService;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
import
javax.servlet.http.HttpServletRequest
;
@RestController
(
"openapiNamespaceController"
)
@RestController
(
"openapiNamespaceController"
)
public
class
NamespaceController
{
public
class
NamespaceController
{
...
@@ -50,7 +48,7 @@ public class NamespaceController {
...
@@ -50,7 +48,7 @@ public class NamespaceController {
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasCreateNamespacePermission(#request, #appId)"
)
@
RequestMapping
(
value
=
"/openapi/v1/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/openapi/v1/apps/{appId}/appnamespaces"
)
public
OpenAppNamespaceDTO
createNamespace
(
@PathVariable
String
appId
,
@RequestBody
OpenAppNamespaceDTO
appNamespaceDTO
,
public
OpenAppNamespaceDTO
createNamespace
(
@PathVariable
String
appId
,
@RequestBody
OpenAppNamespaceDTO
appNamespaceDTO
,
HttpServletRequest
request
)
{
HttpServletRequest
request
)
{
...
@@ -84,7 +82,7 @@ public class NamespaceController {
...
@@ -84,7 +82,7 @@ public class NamespaceController {
return
OpenApiBeanUtils
.
transformToOpenAppNamespaceDTO
(
createdAppNamespace
);
return
OpenApiBeanUtils
.
transformToOpenAppNamespaceDTO
(
createdAppNamespace
);
}
}
@
RequestMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces"
)
public
List
<
OpenNamespaceDTO
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
List
<
OpenNamespaceDTO
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
@PathVariable
String
clusterName
)
{
...
@@ -93,7 +91,7 @@ public class NamespaceController {
...
@@ -93,7 +91,7 @@ public class NamespaceController {
.
fromString
(
env
),
clusterName
));
.
fromString
(
env
),
clusterName
));
}
}
@
RequestMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
OpenNamespaceDTO
loadNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenNamespaceDTO
loadNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
namespaceName
)
{
...
@@ -105,7 +103,7 @@ public class NamespaceController {
...
@@ -105,7 +103,7 @@ public class NamespaceController {
return
OpenApiBeanUtils
.
transformFromNamespaceBO
(
namespaceBO
);
return
OpenApiBeanUtils
.
transformFromNamespaceBO
(
namespaceBO
);
}
}
@
RequestMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/openapi/v1/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
OpenNamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenNamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
String
namespaceName
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/ReleaseController.java
View file @
5d155623
...
@@ -15,13 +15,13 @@ import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel;
...
@@ -15,13 +15,13 @@ import com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel;
import
com.ctrip.framework.apollo.portal.service.NamespaceBranchService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceBranchService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -41,7 +41,7 @@ public class ReleaseController {
...
@@ -41,7 +41,7 @@ public class ReleaseController {
private
NamespaceBranchService
namespaceBranchService
;
private
NamespaceBranchService
namespaceBranchService
;
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
)
public
OpenReleaseDTO
createRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenReleaseDTO
createRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -67,7 +67,7 @@ public class ReleaseController {
...
@@ -67,7 +67,7 @@ public class ReleaseController {
return
OpenApiBeanUtils
.
transformFromReleaseDTO
(
releaseService
.
publish
(
releaseModel
));
return
OpenApiBeanUtils
.
transformFromReleaseDTO
(
releaseService
.
publish
(
releaseModel
));
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/latest"
)
public
OpenReleaseDTO
loadLatestActiveRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenReleaseDTO
loadLatestActiveRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
String
namespaceName
)
{
...
@@ -81,7 +81,7 @@ public class ReleaseController {
...
@@ -81,7 +81,7 @@ public class ReleaseController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge"
)
public
OpenReleaseDTO
merge
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
OpenReleaseDTO
merge
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
...
@@ -103,8 +103,7 @@ public class ReleaseController {
...
@@ -103,8 +103,7 @@ public class ReleaseController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases"
,
@PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases"
)
method
=
RequestMethod
.
POST
)
public
OpenReleaseDTO
createGrayRelease
(
@PathVariable
String
appId
,
public
OpenReleaseDTO
createGrayRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
...
@@ -130,8 +129,7 @@ public class ReleaseController {
...
@@ -130,8 +129,7 @@ public class ReleaseController {
}
}
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@consumerPermissionValidator.hasReleaseNamespacePermission(#request, #appId, #namespaceName, #env)"
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/gray-del-releases"
,
@PostMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/gray-del-releases"
)
method
=
RequestMethod
.
POST
)
public
OpenReleaseDTO
createGrayDelRelease
(
@PathVariable
String
appId
,
public
OpenReleaseDTO
createGrayDelRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/AppController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.entity.App
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.MultiResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.common.http.RichResponseEntity
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.InputValidator
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
com.ctrip.framework.apollo.portal.entity.model.AppModel
;
import
com.ctrip.framework.apollo.portal.entity.model.AppModel
;
import
com.ctrip.framework.apollo.portal.entity.po.Role
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvClusterInfo
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppCreationEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppDeletionEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppDeletionEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppInfoChangedEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppInfoChangedEvent
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
...
@@ -34,14 +30,21 @@ import org.springframework.http.ResponseEntity;
...
@@ -34,14 +30,21 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.HttpClientErrorException
;
import
org.springframework.web.client.HttpClientErrorException
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Set
;
@RestController
@RestController
@RequestMapping
(
"/apps"
)
@RequestMapping
(
"/apps"
)
...
@@ -60,7 +63,7 @@ public class AppController {
...
@@ -60,7 +63,7 @@ public class AppController {
@Autowired
@Autowired
private
RoleInitializationService
roleInitializationService
;
private
RoleInitializationService
roleInitializationService
;
@
RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
GET
)
@
GetMapping
public
List
<
App
>
findApps
(
@RequestParam
(
value
=
"appIds"
,
required
=
false
)
String
appIds
)
{
public
List
<
App
>
findApps
(
@RequestParam
(
value
=
"appIds"
,
required
=
false
)
String
appIds
)
{
if
(
StringUtils
.
isEmpty
(
appIds
))
{
if
(
StringUtils
.
isEmpty
(
appIds
))
{
return
appService
.
findAll
();
return
appService
.
findAll
();
...
@@ -70,7 +73,7 @@ public class AppController {
...
@@ -70,7 +73,7 @@ public class AppController {
}
}
@
RequestMapping
(
value
=
"/by-owner"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/by-owner"
)
public
List
<
App
>
findAppsByOwner
(
@RequestParam
(
"owner"
)
String
owner
,
Pageable
page
)
{
public
List
<
App
>
findAppsByOwner
(
@RequestParam
(
"owner"
)
String
owner
,
Pageable
page
)
{
Set
<
String
>
appIds
=
Sets
.
newHashSet
();
Set
<
String
>
appIds
=
Sets
.
newHashSet
();
...
@@ -87,7 +90,7 @@ public class AppController {
...
@@ -87,7 +90,7 @@ public class AppController {
return
appService
.
findByAppIds
(
appIds
,
page
);
return
appService
.
findByAppIds
(
appIds
,
page
);
}
}
@
RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
POST
)
@
PostMapping
public
App
create
(
@RequestBody
AppModel
appModel
)
{
public
App
create
(
@RequestBody
AppModel
appModel
)
{
App
app
=
transformToApp
(
appModel
);
App
app
=
transformToApp
(
appModel
);
...
@@ -107,7 +110,7 @@ public class AppController {
...
@@ -107,7 +110,7 @@ public class AppController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isAppAdmin(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.isAppAdmin(#appId)"
)
@
RequestMapping
(
value
=
"/{appId:.+}"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/{appId:.+}"
)
public
void
update
(
@PathVariable
String
appId
,
@RequestBody
AppModel
appModel
)
{
public
void
update
(
@PathVariable
String
appId
,
@RequestBody
AppModel
appModel
)
{
if
(!
Objects
.
equals
(
appId
,
appModel
.
getAppId
()))
{
if
(!
Objects
.
equals
(
appId
,
appModel
.
getAppId
()))
{
throw
new
BadRequestException
(
"The App Id of path variable and request body is different"
);
throw
new
BadRequestException
(
"The App Id of path variable and request body is different"
);
...
@@ -120,7 +123,7 @@ public class AppController {
...
@@ -120,7 +123,7 @@ public class AppController {
publisher
.
publishEvent
(
new
AppInfoChangedEvent
(
updatedApp
));
publisher
.
publishEvent
(
new
AppInfoChangedEvent
(
updatedApp
));
}
}
@
RequestMapping
(
value
=
"/{appId}/navtree"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/{appId}/navtree"
)
public
MultiResponseEntity
<
EnvClusterInfo
>
nav
(
@PathVariable
String
appId
)
{
public
MultiResponseEntity
<
EnvClusterInfo
>
nav
(
@PathVariable
String
appId
)
{
MultiResponseEntity
<
EnvClusterInfo
>
response
=
MultiResponseEntity
.
ok
();
MultiResponseEntity
<
EnvClusterInfo
>
response
=
MultiResponseEntity
.
ok
();
...
@@ -137,8 +140,7 @@ public class AppController {
...
@@ -137,8 +140,7 @@ public class AppController {
return
response
;
return
response
;
}
}
@RequestMapping
(
value
=
"/envs/{env}"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
@PostMapping
(
value
=
"/envs/{env}"
,
consumes
=
{
"application/json"
})
"application/json"
})
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
env
,
@RequestBody
App
app
)
{
public
ResponseEntity
<
Void
>
create
(
@PathVariable
String
env
,
@RequestBody
App
app
)
{
RequestPrecondition
.
checkArgumentsNotEmpty
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
RequestPrecondition
.
checkArgumentsNotEmpty
(
app
.
getName
(),
app
.
getAppId
(),
app
.
getOwnerEmail
(),
...
@@ -155,7 +157,7 @@ public class AppController {
...
@@ -155,7 +157,7 @@ public class AppController {
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"/{appId:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/{appId:.+}"
)
public
App
load
(
@PathVariable
String
appId
)
{
public
App
load
(
@PathVariable
String
appId
)
{
return
appService
.
load
(
appId
);
return
appService
.
load
(
appId
);
...
@@ -163,14 +165,14 @@ public class AppController {
...
@@ -163,14 +165,14 @@ public class AppController {
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/{appId:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/{appId:.+}"
)
public
void
deleteApp
(
@PathVariable
String
appId
)
{
public
void
deleteApp
(
@PathVariable
String
appId
)
{
App
app
=
appService
.
deleteAppInLocal
(
appId
);
App
app
=
appService
.
deleteAppInLocal
(
appId
);
publisher
.
publishEvent
(
new
AppDeletionEvent
(
app
));
publisher
.
publishEvent
(
new
AppDeletionEvent
(
app
));
}
}
@
RequestMapping
(
value
=
"/{appId}/miss_envs"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/{appId}/miss_envs"
)
public
MultiResponseEntity
<
Env
>
findMissEnvs
(
@PathVariable
String
appId
)
{
public
MultiResponseEntity
<
Env
>
findMissEnvs
(
@PathVariable
String
appId
)
{
MultiResponseEntity
<
Env
>
response
=
MultiResponseEntity
.
ok
();
MultiResponseEntity
<
Env
>
response
=
MultiResponseEntity
.
ok
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ClusterController.java
View file @
5d155623
...
@@ -7,14 +7,14 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
...
@@ -7,14 +7,14 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.service.ClusterService
;
import
com.ctrip.framework.apollo.portal.service.ClusterService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -30,7 +30,7 @@ public class ClusterController {
...
@@ -30,7 +30,7 @@ public class ClusterController {
private
UserInfoHolder
userInfoHolder
;
private
UserInfoHolder
userInfoHolder
;
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateClusterPermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateClusterPermission(#appId)"
)
@
RequestMapping
(
value
=
"apps/{appId}/envs/{env}/clusters"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"apps/{appId}/envs/{env}/clusters"
)
public
ClusterDTO
createCluster
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
ClusterDTO
createCluster
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@RequestBody
ClusterDTO
cluster
)
{
@RequestBody
ClusterDTO
cluster
)
{
...
@@ -49,14 +49,14 @@ public class ClusterController {
...
@@ -49,14 +49,14 @@ public class ClusterController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"apps/{appId}/envs/{env}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
value
=
"apps/{appId}/envs/{env}/clusters/{clusterName:.+}"
)
public
ResponseEntity
<
Void
>
deleteCluster
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
ResponseEntity
<
Void
>
deleteCluster
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
){
@PathVariable
String
clusterName
){
clusterService
.
deleteCluster
(
Env
.
fromString
(
env
),
appId
,
clusterName
);
clusterService
.
deleteCluster
(
Env
.
fromString
(
env
),
appId
,
clusterName
);
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"apps/{appId}/envs/{env}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"apps/{appId}/envs/{env}/clusters/{clusterName:.+}"
)
public
ClusterDTO
loadCluster
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
String
env
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
public
ClusterDTO
loadCluster
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
String
env
,
@PathVariable
(
"clusterName"
)
String
clusterName
)
{
return
clusterService
.
loadCluster
(
appId
,
Env
.
fromString
(
env
),
clusterName
);
return
clusterService
.
loadCluster
(
appId
,
Env
.
fromString
(
env
),
clusterName
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/CommitController.java
View file @
5d155623
...
@@ -5,15 +5,13 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
...
@@ -5,15 +5,13 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.service.CommitService
;
import
com.ctrip.framework.apollo.portal.service.CommitService
;
import
java.util.Collections
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
...
@@ -26,7 +24,7 @@ public class CommitController {
...
@@ -26,7 +24,7 @@ public class CommitController {
@Autowired
@Autowired
private
PermissionValidator
permissionValidator
;
private
PermissionValidator
permissionValidator
;
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/commits"
)
public
List
<
CommitDTO
>
find
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
List
<
CommitDTO
>
find
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestParam
(
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
defaultValue
=
"10"
)
int
size
)
{
@RequestParam
(
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
defaultValue
=
"10"
)
int
size
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConfigsExportController.java
View file @
5d155623
...
@@ -13,20 +13,21 @@ import com.ctrip.framework.apollo.portal.service.NamespaceService;
...
@@ -13,20 +13,21 @@ import com.ctrip.framework.apollo.portal.service.NamespaceService;
import
com.ctrip.framework.apollo.portal.util.ConfigToFileUtils
;
import
com.ctrip.framework.apollo.portal.util.ConfigToFileUtils
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Joiner
;
import
com.google.common.base.Splitter
;
import
com.google.common.base.Splitter
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletResponse
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.stream.Collectors
;
/**
/**
* jian.tan
* jian.tan
*/
*/
...
@@ -39,7 +40,7 @@ public class ConfigsExportController {
...
@@ -39,7 +40,7 @@ public class ConfigsExportController {
@Autowired
@Autowired
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/import"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/import"
)
public
void
importConfigFile
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
importConfigFile
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestParam
Integer
namespaceId
,
@RequestParam
Integer
namespaceId
,
...
@@ -79,7 +80,7 @@ public class ConfigsExportController {
...
@@ -79,7 +80,7 @@ public class ConfigsExportController {
configService
.
updateConfigItemByText
(
model
);
configService
.
updateConfigItemByText
(
model
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/export"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/export"
)
public
void
exportItems
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
exportItems
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
HttpServletResponse
res
)
{
HttpServletResponse
res
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ConsumerController.java
View file @
5d155623
...
@@ -9,21 +9,26 @@ import com.ctrip.framework.apollo.openapi.entity.Consumer;
...
@@ -9,21 +9,26 @@ import com.ctrip.framework.apollo.openapi.entity.Consumer;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerRole
;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerRole
;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerToken
;
import
com.ctrip.framework.apollo.openapi.entity.ConsumerToken
;
import
com.ctrip.framework.apollo.openapi.service.ConsumerService
;
import
com.ctrip.framework.apollo.openapi.service.ConsumerService
;
import
com.google.common.base.Strings
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.format.annotation.DateTimeFormat
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.GregorianCalendar
;
import
java.util.List
;
import
java.util.Objects
;
/**
/**
* @author Jason Song(song_s@ctrip.com)
* @author Jason Song(song_s@ctrip.com)
...
@@ -39,7 +44,7 @@ public class ConsumerController {
...
@@ -39,7 +44,7 @@ public class ConsumerController {
@Transactional
@Transactional
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/consumers"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/consumers"
)
public
ConsumerToken
createConsumer
(
@RequestBody
Consumer
consumer
,
public
ConsumerToken
createConsumer
(
@RequestBody
Consumer
consumer
,
@RequestParam
(
value
=
"expires"
,
required
=
false
)
@RequestParam
(
value
=
"expires"
,
required
=
false
)
@DateTimeFormat
(
pattern
=
"yyyyMMddHHmmss"
)
Date
@DateTimeFormat
(
pattern
=
"yyyyMMddHHmmss"
)
Date
...
@@ -59,13 +64,13 @@ public class ConsumerController {
...
@@ -59,13 +64,13 @@ public class ConsumerController {
return
consumerService
.
generateAndSaveConsumerToken
(
createdConsumer
,
expires
);
return
consumerService
.
generateAndSaveConsumerToken
(
createdConsumer
,
expires
);
}
}
@
RequestMapping
(
value
=
"/consumers/by-appId"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/consumers/by-appId"
)
public
ConsumerToken
getConsumerTokenByAppId
(
@RequestParam
String
appId
)
{
public
ConsumerToken
getConsumerTokenByAppId
(
@RequestParam
String
appId
)
{
return
consumerService
.
getConsumerTokenByAppId
(
appId
);
return
consumerService
.
getConsumerTokenByAppId
(
appId
);
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/consumers/{token}/assign-role"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/consumers/{token}/assign-role"
)
public
List
<
ConsumerRole
>
assignNamespaceRoleToConsumer
(
@PathVariable
String
token
,
public
List
<
ConsumerRole
>
assignNamespaceRoleToConsumer
(
@PathVariable
String
token
,
@RequestParam
String
type
,
@RequestParam
String
type
,
@RequestParam
(
required
=
false
)
String
envs
,
@RequestParam
(
required
=
false
)
String
envs
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/EnvController.java
View file @
5d155623
...
@@ -2,10 +2,9 @@ package com.ctrip.framework.apollo.portal.controller;
...
@@ -2,10 +2,9 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
com.ctrip.framework.apollo.portal.component.PortalSettings
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.List
;
...
@@ -17,7 +16,7 @@ public class EnvController {
...
@@ -17,7 +16,7 @@ public class EnvController {
@Autowired
@Autowired
private
PortalSettings
portalSettings
;
private
PortalSettings
portalSettings
;
@
RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
GET
)
@
GetMapping
public
List
<
Env
>
envs
()
{
public
List
<
Env
>
envs
()
{
return
portalSettings
.
getActiveEnvs
();
return
portalSettings
.
getActiveEnvs
();
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/FavoriteController.java
View file @
5d155623
...
@@ -2,13 +2,14 @@ package com.ctrip.framework.apollo.portal.controller;
...
@@ -2,13 +2,14 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.portal.entity.po.Favorite
;
import
com.ctrip.framework.apollo.portal.entity.po.Favorite
;
import
com.ctrip.framework.apollo.portal.service.FavoriteService
;
import
com.ctrip.framework.apollo.portal.service.FavoriteService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -21,13 +22,13 @@ public class FavoriteController {
...
@@ -21,13 +22,13 @@ public class FavoriteController {
private
FavoriteService
favoriteService
;
private
FavoriteService
favoriteService
;
@
RequestMapping
(
value
=
"/favorites"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/favorites"
)
public
Favorite
addFavorite
(
@RequestBody
Favorite
favorite
)
{
public
Favorite
addFavorite
(
@RequestBody
Favorite
favorite
)
{
return
favoriteService
.
addFavorite
(
favorite
);
return
favoriteService
.
addFavorite
(
favorite
);
}
}
@
RequestMapping
(
value
=
"/favorites"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/favorites"
)
public
List
<
Favorite
>
findFavorites
(
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
,
public
List
<
Favorite
>
findFavorites
(
@RequestParam
(
value
=
"userId"
,
required
=
false
)
String
userId
,
@RequestParam
(
value
=
"appId"
,
required
=
false
)
String
appId
,
@RequestParam
(
value
=
"appId"
,
required
=
false
)
String
appId
,
Pageable
page
)
{
Pageable
page
)
{
...
@@ -35,13 +36,13 @@ public class FavoriteController {
...
@@ -35,13 +36,13 @@ public class FavoriteController {
}
}
@
RequestMapping
(
value
=
"/favorites/{favoriteId}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/favorites/{favoriteId}"
)
public
void
deleteFavorite
(
@PathVariable
long
favoriteId
)
{
public
void
deleteFavorite
(
@PathVariable
long
favoriteId
)
{
favoriteService
.
deleteFavorite
(
favoriteId
);
favoriteService
.
deleteFavorite
(
favoriteId
);
}
}
@
RequestMapping
(
value
=
"/favorites/{favoriteId}"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/favorites/{favoriteId}"
)
public
void
toTop
(
@PathVariable
long
favoriteId
)
{
public
void
toTop
(
@PathVariable
long
favoriteId
)
{
favoriteService
.
adjustFavoriteToFirst
(
favoriteId
);
favoriteService
.
adjustFavoriteToFirst
(
favoriteId
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/InstanceController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.google.common.base.Splitter
;
import
com.ctrip.framework.apollo.common.dto.InstanceDTO
;
import
com.ctrip.framework.apollo.common.dto.InstanceDTO
;
import
com.ctrip.framework.apollo.common.dto.PageDTO
;
import
com.ctrip.framework.apollo.common.dto.PageDTO
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.entity.vo.Number
;
import
com.ctrip.framework.apollo.portal.entity.vo.Number
;
import
com.ctrip.framework.apollo.portal.service.InstanceService
;
import
com.ctrip.framework.apollo.portal.service.InstanceService
;
import
com.google.common.base.Splitter
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -31,7 +28,7 @@ public class InstanceController {
...
@@ -31,7 +28,7 @@ public class InstanceController {
@Autowired
@Autowired
private
InstanceService
instanceService
;
private
InstanceService
instanceService
;
@
RequestMapping
(
value
=
"/envs/{env}/instances/by-release"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/envs/{env}/instances/by-release"
)
public
PageDTO
<
InstanceDTO
>
getByRelease
(
@PathVariable
String
env
,
@RequestParam
long
releaseId
,
public
PageDTO
<
InstanceDTO
>
getByRelease
(
@PathVariable
String
env
,
@RequestParam
long
releaseId
,
@RequestParam
(
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
defaultValue
=
"20"
)
int
size
)
{
@RequestParam
(
defaultValue
=
"20"
)
int
size
)
{
...
@@ -39,7 +36,7 @@ public class InstanceController {
...
@@ -39,7 +36,7 @@ public class InstanceController {
return
instanceService
.
getByRelease
(
Env
.
valueOf
(
env
),
releaseId
,
page
,
size
);
return
instanceService
.
getByRelease
(
Env
.
valueOf
(
env
),
releaseId
,
page
,
size
);
}
}
@
RequestMapping
(
value
=
"/envs/{env}/instances/by-namespace"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/envs/{env}/instances/by-namespace"
)
public
PageDTO
<
InstanceDTO
>
getByNamespace
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
public
PageDTO
<
InstanceDTO
>
getByNamespace
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
@RequestParam
String
clusterName
,
@RequestParam
String
namespaceName
,
@RequestParam
String
clusterName
,
@RequestParam
String
namespaceName
,
@RequestParam
(
required
=
false
)
String
instanceAppId
,
@RequestParam
(
required
=
false
)
String
instanceAppId
,
...
@@ -49,7 +46,7 @@ public class InstanceController {
...
@@ -49,7 +46,7 @@ public class InstanceController {
return
instanceService
.
getByNamespace
(
Env
.
valueOf
(
env
),
appId
,
clusterName
,
namespaceName
,
instanceAppId
,
page
,
size
);
return
instanceService
.
getByNamespace
(
Env
.
valueOf
(
env
),
appId
,
clusterName
,
namespaceName
,
instanceAppId
,
page
,
size
);
}
}
@
RequestMapping
(
value
=
"/envs/{env}/instances/by-namespace/count"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/envs/{env}/instances/by-namespace/count"
)
public
ResponseEntity
<
Number
>
getInstanceCountByNamespace
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
public
ResponseEntity
<
Number
>
getInstanceCountByNamespace
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
@RequestParam
String
clusterName
,
@RequestParam
String
clusterName
,
@RequestParam
String
namespaceName
)
{
@RequestParam
String
namespaceName
)
{
...
@@ -58,7 +55,7 @@ public class InstanceController {
...
@@ -58,7 +55,7 @@ public class InstanceController {
return
ResponseEntity
.
ok
(
new
Number
(
count
));
return
ResponseEntity
.
ok
(
new
Number
(
count
));
}
}
@
RequestMapping
(
value
=
"/envs/{env}/instances/by-namespace-and-releases-not-in"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/envs/{env}/instances/by-namespace-and-releases-not-in"
)
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
public
List
<
InstanceDTO
>
getByReleasesNotIn
(
@PathVariable
String
env
,
@RequestParam
String
appId
,
@RequestParam
String
clusterName
,
@RequestParam
String
namespaceName
,
@RequestParam
String
clusterName
,
@RequestParam
String
namespaceName
,
@RequestParam
String
releaseIds
)
{
@RequestParam
String
releaseIds
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ItemController.java
View file @
5d155623
...
@@ -12,16 +12,17 @@ import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
...
@@ -12,16 +12,17 @@ import com.ctrip.framework.apollo.portal.entity.vo.ItemDiffs;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceIdentifier
;
import
com.ctrip.framework.apollo.portal.service.ItemService
;
import
com.ctrip.framework.apollo.portal.service.ItemService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -42,7 +43,7 @@ public class ItemController {
...
@@ -42,7 +43,7 @@ public class ItemController {
private
PermissionValidator
permissionValidator
;
private
PermissionValidator
permissionValidator
;
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
PUT
,
consumes
=
{
@
PutMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
consumes
=
{
"application/json"
})
"application/json"
})
public
void
modifyItemsByText
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
modifyItemsByText
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
...
@@ -59,7 +60,7 @@ public class ItemController {
...
@@ -59,7 +60,7 @@ public class ItemController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
)
public
ItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
ItemDTO
createItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
ItemDTO
item
)
{
@RequestBody
ItemDTO
item
)
{
...
@@ -78,7 +79,7 @@ public class ItemController {
...
@@ -78,7 +79,7 @@ public class ItemController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/item"
)
public
void
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
updateItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
ItemDTO
item
)
{
@RequestBody
ItemDTO
item
)
{
...
@@ -92,7 +93,7 @@ public class ItemController {
...
@@ -92,7 +93,7 @@ public class ItemController {
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env) "
)
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env) "
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items/{itemId}"
)
public
void
deleteItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
deleteItem
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
long
itemId
)
{
@PathVariable
long
itemId
)
{
...
@@ -103,7 +104,7 @@ public class ItemController {
...
@@ -103,7 +104,7 @@ public class ItemController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/items"
)
public
List
<
ItemDTO
>
findItems
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
List
<
ItemDTO
>
findItems
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestParam
(
defaultValue
=
"lineNum"
)
String
orderBy
)
{
@RequestParam
(
defaultValue
=
"lineNum"
)
String
orderBy
)
{
...
@@ -127,7 +128,7 @@ public class ItemController {
...
@@ -127,7 +128,7 @@ public class ItemController {
return
items
;
return
items
;
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/items"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/items"
)
public
List
<
ItemDTO
>
findBranchItems
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
String
env
,
public
List
<
ItemDTO
>
findBranchItems
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
String
env
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
@PathVariable
(
"namespaceName"
)
String
namespaceName
,
...
@@ -136,8 +137,7 @@ public class ItemController {
...
@@ -136,8 +137,7 @@ public class ItemController {
return
findItems
(
appId
,
env
,
branchName
,
namespaceName
,
"lastModifiedTime"
);
return
findItems
(
appId
,
env
,
branchName
,
namespaceName
,
"lastModifiedTime"
);
}
}
@RequestMapping
(
value
=
"/namespaces/{namespaceName}/diff"
,
method
=
RequestMethod
.
POST
,
consumes
=
{
@PostMapping
(
value
=
"/namespaces/{namespaceName}/diff"
,
consumes
=
{
"application/json"
})
"application/json"
})
public
List
<
ItemDiffs
>
diff
(
@RequestBody
NamespaceSyncModel
model
)
{
public
List
<
ItemDiffs
>
diff
(
@RequestBody
NamespaceSyncModel
model
)
{
checkModel
(
Objects
.
nonNull
(
model
)
&&
!
model
.
isInvalid
());
checkModel
(
Objects
.
nonNull
(
model
)
&&
!
model
.
isInvalid
());
...
@@ -159,8 +159,7 @@ public class ItemController {
...
@@ -159,8 +159,7 @@ public class ItemController {
return
itemDiffs
;
return
itemDiffs
;
}
}
@RequestMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/items"
,
method
=
RequestMethod
.
PUT
,
consumes
=
{
@PutMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/items"
,
consumes
=
{
"application/json"
})
"application/json"
})
public
ResponseEntity
<
Void
>
update
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
Void
>
update
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@RequestBody
NamespaceSyncModel
model
)
{
@RequestBody
NamespaceSyncModel
model
)
{
checkModel
(
Objects
.
nonNull
(
model
)
&&
!
model
.
isInvalid
());
checkModel
(
Objects
.
nonNull
(
model
)
&&
!
model
.
isInvalid
());
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java
View file @
5d155623
...
@@ -7,20 +7,21 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
...
@@ -7,20 +7,21 @@ import com.ctrip.framework.apollo.common.exception.BadRequestException;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
import
com.ctrip.framework.apollo.portal.service.NamespaceBranchService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceBranchService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -38,7 +39,7 @@ public class NamespaceBranchController {
...
@@ -38,7 +39,7 @@ public class NamespaceBranchController {
@Autowired
@Autowired
private
PortalConfig
portalConfig
;
private
PortalConfig
portalConfig
;
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceBO
findBranch
(
@PathVariable
String
appId
,
public
NamespaceBO
findBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -53,7 +54,7 @@ public class NamespaceBranchController {
...
@@ -53,7 +54,7 @@ public class NamespaceBranchController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasModifyNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
NamespaceDTO
createBranch
(
@PathVariable
String
appId
,
public
NamespaceDTO
createBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -62,7 +63,7 @@ public class NamespaceBranchController {
...
@@ -62,7 +63,7 @@ public class NamespaceBranchController {
return
namespaceBranchService
.
createBranch
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
return
namespaceBranchService
.
createBranch
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}"
)
public
void
deleteBranch
(
@PathVariable
String
appId
,
public
void
deleteBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -88,7 +89,7 @@ public class NamespaceBranchController {
...
@@ -88,7 +89,7 @@ public class NamespaceBranchController {
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/merge"
)
public
ReleaseDTO
merge
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
ReleaseDTO
merge
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
@PathVariable
String
branchName
,
@RequestParam
(
value
=
"deleteBranch"
,
defaultValue
=
"true"
)
boolean
deleteBranch
,
...
@@ -116,7 +117,7 @@ public class NamespaceBranchController {
...
@@ -116,7 +117,7 @@ public class NamespaceBranchController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
public
GrayReleaseRuleDTO
getBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
GrayReleaseRuleDTO
getBranchGrayRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -127,7 +128,7 @@ public class NamespaceBranchController {
...
@@ -127,7 +128,7 @@ public class NamespaceBranchController {
@PreAuthorize
(
value
=
"@permissionValidator.hasOperateNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasOperateNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/rules"
)
public
void
updateBranchRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
void
updateBranchRules
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@RequestBody
GrayReleaseRuleDTO
rules
)
{
@PathVariable
String
branchName
,
@RequestBody
GrayReleaseRuleDTO
rules
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
static
com
.
ctrip
.
framework
.
apollo
.
common
.
utils
.
RequestPrecondition
.
checkModel
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.AppNamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
...
@@ -25,10 +23,6 @@ import com.ctrip.framework.apollo.portal.service.RoleInitializationService;
...
@@ -25,10 +23,6 @@ import com.ctrip.framework.apollo.portal.service.RoleInitializationService;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.ctrip.framework.apollo.tracer.Tracer
;
import
com.google.common.collect.Sets
;
import
com.google.common.collect.Sets
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -36,13 +30,21 @@ import org.springframework.context.ApplicationEventPublisher;
...
@@ -36,13 +30,21 @@ import org.springframework.context.ApplicationEventPublisher;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
static
com
.
ctrip
.
framework
.
apollo
.
common
.
utils
.
RequestPrecondition
.
checkModel
;
@RestController
@RestController
public
class
NamespaceController
{
public
class
NamespaceController
{
...
@@ -66,12 +68,12 @@ public class NamespaceController {
...
@@ -66,12 +68,12 @@ public class NamespaceController {
private
AdminServiceAPI
.
NamespaceAPI
namespaceAPI
;
private
AdminServiceAPI
.
NamespaceAPI
namespaceAPI
;
@
RequestMapping
(
value
=
"/appnamespaces/public"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/appnamespaces/public"
)
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
public
List
<
AppNamespace
>
findPublicAppNamespaces
()
{
return
appNamespaceService
.
findPublicAppNamespaces
();
return
appNamespaceService
.
findPublicAppNamespaces
();
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces"
)
public
List
<
NamespaceBO
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
List
<
NamespaceBO
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
@PathVariable
String
clusterName
)
{
...
@@ -86,7 +88,7 @@ public class NamespaceController {
...
@@ -86,7 +88,7 @@ public class NamespaceController {
return
namespaceBOs
;
return
namespaceBOs
;
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
NamespaceBO
findNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
NamespaceBO
findNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
...
@@ -99,8 +101,7 @@ public class NamespaceController {
...
@@ -99,8 +101,7 @@ public class NamespaceController {
return
namespaceBO
;
return
namespaceBO
;
}
}
@RequestMapping
(
value
=
"/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
,
@GetMapping
(
"/envs/{env}/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/associated-public-namespace"
)
method
=
RequestMethod
.
GET
)
public
NamespaceBO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
env
,
public
NamespaceBO
findPublicNamespaceForAssociatedNamespace
(
@PathVariable
String
env
,
@PathVariable
String
appId
,
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
@@ -110,7 +111,7 @@ public class NamespaceController {
...
@@ -110,7 +111,7 @@ public class NamespaceController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateNamespacePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateNamespacePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/namespaces"
)
public
ResponseEntity
<
Void
>
createNamespace
(
@PathVariable
String
appId
,
public
ResponseEntity
<
Void
>
createNamespace
(
@PathVariable
String
appId
,
@RequestBody
List
<
NamespaceCreationModel
>
models
)
{
@RequestBody
List
<
NamespaceCreationModel
>
models
)
{
...
@@ -143,7 +144,7 @@ public class NamespaceController {
...
@@ -143,7 +144,7 @@ public class NamespaceController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasDeleteNamespacePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasDeleteNamespacePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
ResponseEntity
<
Void
>
deleteNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
ResponseEntity
<
Void
>
deleteNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
...
@@ -153,7 +154,7 @@ public class NamespaceController {
...
@@ -153,7 +154,7 @@ public class NamespaceController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
)
public
ResponseEntity
<
Void
>
deleteAppNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
public
ResponseEntity
<
Void
>
deleteAppNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
AppNamespace
appNamespace
=
appNamespaceService
.
deleteAppNamespace
(
appId
,
namespaceName
);
AppNamespace
appNamespace
=
appNamespaceService
.
deleteAppNamespace
(
appId
,
namespaceName
);
...
@@ -163,7 +164,7 @@ public class NamespaceController {
...
@@ -163,7 +164,7 @@ public class NamespaceController {
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/appnamespaces/{namespaceName:.+}"
)
public
AppNamespaceDTO
findAppNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
public
AppNamespaceDTO
findAppNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
...
@@ -176,7 +177,7 @@ public class NamespaceController {
...
@@ -176,7 +177,7 @@ public class NamespaceController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateAppNamespacePermission(#appId, #appNamespace)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateAppNamespacePermission(#appId, #appNamespace)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/appnamespaces"
)
public
AppNamespace
createAppNamespace
(
@PathVariable
String
appId
,
public
AppNamespace
createAppNamespace
(
@PathVariable
String
appId
,
@RequestParam
(
defaultValue
=
"true"
)
boolean
appendNamespacePrefix
,
@RequestParam
(
defaultValue
=
"true"
)
boolean
appendNamespacePrefix
,
@RequestBody
AppNamespace
appNamespace
)
{
@RequestBody
AppNamespace
appNamespace
)
{
...
@@ -207,12 +208,12 @@ public class NamespaceController {
...
@@ -207,12 +208,12 @@ public class NamespaceController {
* default -> true (default cluster has not published namespace)
* default -> true (default cluster has not published namespace)
* customCluster -> false (customCluster cluster's all namespaces had published)
* customCluster -> false (customCluster cluster's all namespaces had published)
*/
*/
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/publish_info"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/namespaces/publish_info"
)
public
Map
<
String
,
Map
<
String
,
Boolean
>>
getNamespacesPublishInfo
(
@PathVariable
String
appId
)
{
public
Map
<
String
,
Map
<
String
,
Boolean
>>
getNamespacesPublishInfo
(
@PathVariable
String
appId
)
{
return
namespaceService
.
getNamespacesPublishInfo
(
appId
);
return
namespaceService
.
getNamespacesPublishInfo
(
appId
);
}
}
@
RequestMapping
(
value
=
"/envs/{env}/appnamespaces/{publicNamespaceName}/namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/envs/{env}/appnamespaces/{publicNamespaceName}/namespaces"
)
public
List
<
NamespaceDTO
>
getPublicAppNamespaceAllNamespaces
(
@PathVariable
String
env
,
public
List
<
NamespaceDTO
>
getPublicAppNamespaceAllNamespaces
(
@PathVariable
String
env
,
@PathVariable
String
publicNamespaceName
,
@PathVariable
String
publicNamespaceName
,
@RequestParam
(
name
=
"page"
,
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
name
=
"page"
,
defaultValue
=
"0"
)
int
page
,
...
@@ -222,7 +223,7 @@ public class NamespaceController {
...
@@ -222,7 +223,7 @@ public class NamespaceController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/missing-namespaces"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/missing-namespaces"
)
public
MultiResponseEntity
<
String
>
findMissingNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
public
MultiResponseEntity
<
String
>
findMissingNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
MultiResponseEntity
<
String
>
response
=
MultiResponseEntity
.
ok
();
MultiResponseEntity
<
String
>
response
=
MultiResponseEntity
.
ok
();
...
@@ -236,7 +237,7 @@ public class NamespaceController {
...
@@ -236,7 +237,7 @@ public class NamespaceController {
return
response
;
return
response
;
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/missing-namespaces"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/missing-namespaces"
)
public
ResponseEntity
<
Void
>
createMissingNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
public
ResponseEntity
<
Void
>
createMissingNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
Set
<
String
>
missingNamespaces
=
findMissingNamespaceNames
(
appId
,
env
,
clusterName
);
Set
<
String
>
missingNamespaces
=
findMissingNamespaceNames
(
appId
,
env
,
clusterName
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceLockController.java
View file @
5d155623
...
@@ -4,11 +4,9 @@ import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO;
...
@@ -4,11 +4,9 @@ import com.ctrip.framework.apollo.common.dto.NamespaceLockDTO;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.entity.vo.LockInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.LockInfo
;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
com.ctrip.framework.apollo.portal.service.NamespaceLockService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -18,14 +16,14 @@ public class NamespaceLockController {
...
@@ -18,14 +16,14 @@ public class NamespaceLockController {
private
NamespaceLockService
namespaceLockService
;
private
NamespaceLockService
namespaceLockService
;
@Deprecated
@Deprecated
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
)
public
NamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
NamespaceLockDTO
getNamespaceLock
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
return
namespaceLockService
.
getNamespaceLock
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
return
namespaceLockService
.
getNamespaceLock
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock-info"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/lock-info"
)
public
LockInfo
getNamespaceLockInfo
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
LockInfo
getNamespaceLockInfo
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PageSettingController.java
View file @
5d155623
...
@@ -2,10 +2,8 @@ package com.ctrip.framework.apollo.portal.controller;
...
@@ -2,10 +2,8 @@ package com.ctrip.framework.apollo.portal.controller;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.vo.PageSetting
;
import
com.ctrip.framework.apollo.portal.entity.vo.PageSetting
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RestController
...
@@ -14,7 +12,7 @@ public class PageSettingController {
...
@@ -14,7 +12,7 @@ public class PageSettingController {
@Autowired
@Autowired
private
PortalConfig
portalConfig
;
private
PortalConfig
portalConfig
;
@
RequestMapping
(
value
=
"/page-settings"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/page-settings"
)
public
PageSetting
getPageSetting
()
{
public
PageSetting
getPageSetting
()
{
PageSetting
setting
=
new
PageSetting
();
PageSetting
setting
=
new
PageSetting
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/PermissionController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.EnvUtils
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceEnvRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.google.common.collect.Sets
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.common.utils.RequestPrecondition
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.EnvUtils
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.bo.UserInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.AppRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.AppRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceEnvRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceRolesAssignedUsers
;
import
com.ctrip.framework.apollo.portal.entity.vo.PermissionCondition
;
import
com.ctrip.framework.apollo.portal.entity.vo.PermissionCondition
;
import
com.ctrip.framework.apollo.portal.service.RoleInitializationService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.service.RolePermissionService
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.ctrip.framework.apollo.portal.util.RoleUtils
;
import
com.google.common.collect.Sets
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.bind.annotation.DeleteMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
...
@@ -44,13 +43,13 @@ public class PermissionController {
...
@@ -44,13 +43,13 @@ public class PermissionController {
@Autowired
@Autowired
private
RoleInitializationService
roleInitializationService
;
private
RoleInitializationService
roleInitializationService
;
@
RequestMapping
(
value
=
"/apps/{appId}/initPermission"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/initPermission"
)
public
ResponseEntity
<
Void
>
initAppPermission
(
@PathVariable
String
appId
,
@RequestBody
String
namespaceName
)
{
public
ResponseEntity
<
Void
>
initAppPermission
(
@PathVariable
String
appId
,
@RequestBody
String
namespaceName
)
{
roleInitializationService
.
initNamespaceEnvRoles
(
appId
,
namespaceName
,
userInfoHolder
.
getUser
().
getUserId
());
roleInitializationService
.
initNamespaceEnvRoles
(
appId
,
namespaceName
,
userInfoHolder
.
getUser
().
getUserId
());
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/permissions/{permissionType}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/permissions/{permissionType}"
)
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
permissionType
)
{
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
permissionType
)
{
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
...
@@ -60,7 +59,7 @@ public class PermissionController {
...
@@ -60,7 +59,7 @@ public class PermissionController {
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/permissions/{permissionType}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/namespaces/{namespaceName}/permissions/{permissionType}"
)
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@PathVariable
String
permissionType
)
{
@PathVariable
String
permissionType
)
{
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
...
@@ -72,7 +71,7 @@ public class PermissionController {
...
@@ -72,7 +71,7 @@ public class PermissionController {
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/permissions/{permissionType}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/permissions/{permissionType}"
)
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
PermissionCondition
>
hasPermission
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
@PathVariable
String
permissionType
)
{
@PathVariable
String
permissionType
)
{
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
...
@@ -84,7 +83,7 @@ public class PermissionController {
...
@@ -84,7 +83,7 @@ public class PermissionController {
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
return
ResponseEntity
.
ok
().
body
(
permissionCondition
);
}
}
@
RequestMapping
(
value
=
"/permissions/root"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/permissions/root"
)
public
ResponseEntity
<
PermissionCondition
>
hasRootPermission
()
{
public
ResponseEntity
<
PermissionCondition
>
hasRootPermission
()
{
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
PermissionCondition
permissionCondition
=
new
PermissionCondition
();
...
@@ -94,7 +93,7 @@ public class PermissionController {
...
@@ -94,7 +93,7 @@ public class PermissionController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/role_users"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/role_users"
)
public
NamespaceEnvRolesAssignedUsers
getNamespaceEnvRoles
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
)
{
public
NamespaceEnvRolesAssignedUsers
getNamespaceEnvRoles
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
)
{
// validate env parameter
// validate env parameter
...
@@ -119,7 +118,7 @@ public class PermissionController {
...
@@ -119,7 +118,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
assignNamespaceEnvRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
Void
>
assignNamespaceEnvRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
@PathVariable
String
roleType
,
@RequestBody
String
user
)
{
@PathVariable
String
roleType
,
@RequestBody
String
user
)
{
checkUserExists
(
user
);
checkUserExists
(
user
);
...
@@ -143,7 +142,7 @@ public class PermissionController {
...
@@ -143,7 +142,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/envs/{env}/namespaces/{namespaceName}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
removeNamespaceEnvRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
Void
>
removeNamespaceEnvRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
@PathVariable
String
roleType
,
@RequestParam
String
user
)
{
@PathVariable
String
roleType
,
@RequestParam
String
user
)
{
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
...
@@ -160,7 +159,7 @@ public class PermissionController {
...
@@ -160,7 +159,7 @@ public class PermissionController {
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/role_users"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/namespaces/{namespaceName}/role_users"
)
public
NamespaceRolesAssignedUsers
getNamespaceRoles
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
public
NamespaceRolesAssignedUsers
getNamespaceRoles
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
)
{
NamespaceRolesAssignedUsers
assignedUsers
=
new
NamespaceRolesAssignedUsers
();
NamespaceRolesAssignedUsers
assignedUsers
=
new
NamespaceRolesAssignedUsers
();
...
@@ -179,7 +178,7 @@ public class PermissionController {
...
@@ -179,7 +178,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
assignNamespaceRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
Void
>
assignNamespaceRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@PathVariable
String
roleType
,
@RequestBody
String
user
)
{
@PathVariable
String
roleType
,
@RequestBody
String
user
)
{
checkUserExists
(
user
);
checkUserExists
(
user
);
...
@@ -198,7 +197,7 @@ public class PermissionController {
...
@@ -198,7 +197,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/namespaces/{namespaceName}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
removeNamespaceRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
public
ResponseEntity
<
Void
>
removeNamespaceRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
namespaceName
,
@PathVariable
String
roleType
,
@RequestParam
String
user
)
{
@PathVariable
String
roleType
,
@RequestParam
String
user
)
{
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
...
@@ -211,7 +210,7 @@ public class PermissionController {
...
@@ -211,7 +210,7 @@ public class PermissionController {
return
ResponseEntity
.
ok
().
build
();
return
ResponseEntity
.
ok
().
build
();
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/role_users"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/apps/{appId}/role_users"
)
public
AppRolesAssignedUsers
getAppRoles
(
@PathVariable
String
appId
)
{
public
AppRolesAssignedUsers
getAppRoles
(
@PathVariable
String
appId
)
{
AppRolesAssignedUsers
users
=
new
AppRolesAssignedUsers
();
AppRolesAssignedUsers
users
=
new
AppRolesAssignedUsers
();
users
.
setAppId
(
appId
);
users
.
setAppId
(
appId
);
...
@@ -223,7 +222,7 @@ public class PermissionController {
...
@@ -223,7 +222,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/roles/{roleType}"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/apps/{appId}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
assignAppRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
roleType
,
public
ResponseEntity
<
Void
>
assignAppRoleToUser
(
@PathVariable
String
appId
,
@PathVariable
String
roleType
,
@RequestBody
String
user
)
{
@RequestBody
String
user
)
{
checkUserExists
(
user
);
checkUserExists
(
user
);
...
@@ -242,7 +241,7 @@ public class PermissionController {
...
@@ -242,7 +241,7 @@ public class PermissionController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasAssignRolePermission(#appId)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/roles/{roleType}"
,
method
=
RequestMethod
.
DELETE
)
@
DeleteMapping
(
"/apps/{appId}/roles/{roleType}"
)
public
ResponseEntity
<
Void
>
removeAppRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
roleType
,
public
ResponseEntity
<
Void
>
removeAppRoleFromUser
(
@PathVariable
String
appId
,
@PathVariable
String
roleType
,
@RequestParam
String
user
)
{
@RequestParam
String
user
)
{
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
RequestPrecondition
.
checkArgumentsNotEmpty
(
user
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java
View file @
5d155623
...
@@ -7,24 +7,24 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
...
@@ -7,24 +7,24 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.component.config.PortalConfig
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceReleaseModel
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.vo.ReleaseCompareResult
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseBO
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
import
com.ctrip.framework.apollo.portal.listener.ConfigPublishEvent
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseService
;
import
java.util.Collections
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.AccessDeniedException
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -43,7 +43,7 @@ public class ReleaseController {
...
@@ -43,7 +43,7 @@ public class ReleaseController {
private
PermissionValidator
permissionValidator
;
private
PermissionValidator
permissionValidator
;
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases"
)
public
ReleaseDTO
createRelease
(
@PathVariable
String
appId
,
public
ReleaseDTO
createRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@RequestBody
NamespaceReleaseModel
model
)
{
@PathVariable
String
namespaceName
,
@RequestBody
NamespaceReleaseModel
model
)
{
...
@@ -74,8 +74,7 @@ public class ReleaseController {
...
@@ -74,8 +74,7 @@ public class ReleaseController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasReleaseNamespacePermission(#appId, #namespaceName, #env)"
)
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases"
,
@PostMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches/{branchName}/releases"
)
method
=
RequestMethod
.
POST
)
public
ReleaseDTO
createGrayRelease
(
@PathVariable
String
appId
,
public
ReleaseDTO
createGrayRelease
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
branchName
,
...
@@ -107,7 +106,7 @@ public class ReleaseController {
...
@@ -107,7 +106,7 @@ public class ReleaseController {
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
)
public
List
<
ReleaseBO
>
findAllReleases
(
@PathVariable
String
appId
,
public
List
<
ReleaseBO
>
findAllReleases
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -124,7 +123,7 @@ public class ReleaseController {
...
@@ -124,7 +123,7 @@ public class ReleaseController {
return
releaseService
.
findAllReleases
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
page
,
size
);
return
releaseService
.
findAllReleases
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
page
,
size
);
}
}
@
RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/active"
)
public
List
<
ReleaseDTO
>
findActiveReleases
(
@PathVariable
String
appId
,
public
List
<
ReleaseDTO
>
findActiveReleases
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
@@ -142,7 +141,7 @@ public class ReleaseController {
...
@@ -142,7 +141,7 @@ public class ReleaseController {
return
releaseService
.
findActiveReleases
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
page
,
size
);
return
releaseService
.
findActiveReleases
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
,
page
,
size
);
}
}
@
RequestMapping
(
value
=
"/envs/{env}/releases/compare"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/envs/{env}/releases/compare"
)
public
ReleaseCompareResult
compareRelease
(
@PathVariable
String
env
,
public
ReleaseCompareResult
compareRelease
(
@PathVariable
String
env
,
@RequestParam
long
baseReleaseId
,
@RequestParam
long
baseReleaseId
,
@RequestParam
long
toCompareReleaseId
)
{
@RequestParam
long
toCompareReleaseId
)
{
...
@@ -151,7 +150,7 @@ public class ReleaseController {
...
@@ -151,7 +150,7 @@ public class ReleaseController {
}
}
@
RequestMapping
(
path
=
"/envs/{env}/releases/{releaseId}/rollback"
,
method
=
RequestMethod
.
PUT
)
@
PutMapping
(
path
=
"/envs/{env}/releases/{releaseId}/rollback"
)
public
void
rollback
(
@PathVariable
String
env
,
public
void
rollback
(
@PathVariable
String
env
,
@PathVariable
long
releaseId
)
{
@PathVariable
long
releaseId
)
{
ReleaseDTO
release
=
releaseService
.
findReleaseById
(
Env
.
valueOf
(
env
),
releaseId
);
ReleaseDTO
release
=
releaseService
.
findReleaseById
(
Env
.
valueOf
(
env
),
releaseId
);
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseHistoryController.java
View file @
5d155623
...
@@ -5,15 +5,13 @@ import com.ctrip.framework.apollo.core.enums.Env;
...
@@ -5,15 +5,13 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.component.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.ReleaseHistoryBO
;
import
com.ctrip.framework.apollo.portal.service.ReleaseHistoryService
;
import
com.ctrip.framework.apollo.portal.service.ReleaseHistoryService
;
import
java.util.Collections
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
@RestController
@RestController
...
@@ -24,8 +22,7 @@ public class ReleaseHistoryController {
...
@@ -24,8 +22,7 @@ public class ReleaseHistoryController {
@Autowired
@Autowired
private
PermissionValidator
permissionValidator
;
private
PermissionValidator
permissionValidator
;
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories"
,
@GetMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories"
)
method
=
RequestMethod
.
GET
)
public
List
<
ReleaseHistoryBO
>
findReleaseHistoriesByNamespace
(
@PathVariable
String
appId
,
public
List
<
ReleaseHistoryBO
>
findReleaseHistoriesByNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ServerConfigController.java
View file @
5d155623
...
@@ -6,13 +6,12 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
...
@@ -6,13 +6,12 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.entity.po.ServerConfig
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
com.ctrip.framework.apollo.portal.repository.ServerConfigRepository
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Objects
;
import
java.util.Objects
;
...
@@ -31,7 +30,7 @@ public class ServerConfigController {
...
@@ -31,7 +30,7 @@ public class ServerConfigController {
private
UserInfoHolder
userInfoHolder
;
private
UserInfoHolder
userInfoHolder
;
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/server/config"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/server/config"
)
public
ServerConfig
createOrUpdate
(
@RequestBody
ServerConfig
serverConfig
)
{
public
ServerConfig
createOrUpdate
(
@RequestBody
ServerConfig
serverConfig
)
{
checkModel
(
Objects
.
nonNull
(
serverConfig
));
checkModel
(
Objects
.
nonNull
(
serverConfig
));
...
@@ -54,7 +53,7 @@ public class ServerConfigController {
...
@@ -54,7 +53,7 @@ public class ServerConfigController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/server/config/{key:.+}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/server/config/{key:.+}"
)
public
ServerConfig
loadServerConfig
(
@PathVariable
String
key
)
{
public
ServerConfig
loadServerConfig
(
@PathVariable
String
key
)
{
return
serverConfigRepository
.
findByKey
(
key
);
return
serverConfigRepository
.
findByKey
(
key
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SignInController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
/**
/**
...
@@ -11,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
...
@@ -11,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam;
@Controller
@Controller
public
class
SignInController
{
public
class
SignInController
{
@
RequestMapping
(
value
=
"/signin"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/signin"
)
public
String
login
(
@RequestParam
(
value
=
"error"
,
required
=
false
)
String
error
,
public
String
login
(
@RequestParam
(
value
=
"error"
,
required
=
false
)
String
error
,
@RequestParam
(
value
=
"logout"
,
required
=
false
)
String
logout
)
{
@RequestParam
(
value
=
"logout"
,
required
=
false
)
String
logout
)
{
return
"login.html"
;
return
"login.html"
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SsoHeartbeatController.java
View file @
5d155623
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
controller
;
import
com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler
;
import
com.ctrip.framework.apollo.portal.spi.SsoHeartbeatHandler
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -22,7 +21,7 @@ public class SsoHeartbeatController {
...
@@ -22,7 +21,7 @@ public class SsoHeartbeatController {
@Autowired
@Autowired
private
SsoHeartbeatHandler
handler
;
private
SsoHeartbeatHandler
handler
;
@
RequestMapping
(
value
=
""
,
method
=
RequestMethod
.
GET
)
@
GetMapping
public
void
heartbeat
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
void
heartbeat
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
handler
.
doHeartbeat
(
request
,
response
);
handler
.
doHeartbeat
(
request
,
response
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/SystemInfoController.java
View file @
5d155623
...
@@ -8,19 +8,20 @@ import com.ctrip.framework.apollo.portal.component.PortalSettings;
...
@@ -8,19 +8,20 @@ import com.ctrip.framework.apollo.portal.component.PortalSettings;
import
com.ctrip.framework.apollo.portal.component.RestTemplateFactory
;
import
com.ctrip.framework.apollo.portal.component.RestTemplateFactory
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvironmentInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.EnvironmentInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.SystemInfo
;
import
com.ctrip.framework.apollo.portal.entity.vo.SystemInfo
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.boot.actuate.health.Health
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.PostConstruct
;
import
java.util.List
;
@RestController
@RestController
@RequestMapping
(
"/system-info"
)
@RequestMapping
(
"/system-info"
)
public
class
SystemInfoController
{
public
class
SystemInfoController
{
...
@@ -43,7 +44,7 @@ public class SystemInfoController {
...
@@ -43,7 +44,7 @@ public class SystemInfoController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
method
=
RequestMethod
.
GET
)
@
GetMapping
public
SystemInfo
getSystemInfo
()
{
public
SystemInfo
getSystemInfo
()
{
SystemInfo
systemInfo
=
new
SystemInfo
();
SystemInfo
systemInfo
=
new
SystemInfo
();
...
@@ -80,7 +81,7 @@ public class SystemInfoController {
...
@@ -80,7 +81,7 @@ public class SystemInfoController {
}
}
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/health"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
value
=
"/health"
)
public
Health
checkHealth
(
@RequestParam
String
host
)
{
public
Health
checkHealth
(
@RequestParam
String
host
)
{
return
restTemplate
.
getForObject
(
host
+
"/health"
,
Health
.
class
);
return
restTemplate
.
getForObject
(
host
+
"/health"
,
Health
.
class
);
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/UserInfoController.java
View file @
5d155623
...
@@ -8,21 +8,19 @@ import com.ctrip.framework.apollo.portal.spi.LogoutHandler;
...
@@ -8,21 +8,19 @@ import com.ctrip.framework.apollo.portal.spi.LogoutHandler;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserInfoHolder
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.UserService
;
import
com.ctrip.framework.apollo.portal.spi.springsecurity.SpringSecurityUserService
;
import
com.ctrip.framework.apollo.portal.spi.springsecurity.SpringSecurityUserService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.io.IOException
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
@RestController
@RestController
public
class
UserInfoController
{
public
class
UserInfoController
{
...
@@ -37,7 +35,7 @@ public class UserInfoController {
...
@@ -37,7 +35,7 @@ public class UserInfoController {
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@PreAuthorize
(
value
=
"@permissionValidator.isSuperAdmin()"
)
@
RequestMapping
(
value
=
"/users"
,
method
=
RequestMethod
.
POST
)
@
PostMapping
(
"/users"
)
public
void
createOrUpdateUser
(
@RequestBody
UserPO
user
)
{
public
void
createOrUpdateUser
(
@RequestBody
UserPO
user
)
{
if
(
StringUtils
.
isContainEmpty
(
user
.
getUsername
(),
user
.
getPassword
()))
{
if
(
StringUtils
.
isContainEmpty
(
user
.
getUsername
(),
user
.
getPassword
()))
{
throw
new
BadRequestException
(
"Username and password can not be empty."
);
throw
new
BadRequestException
(
"Username and password can not be empty."
);
...
@@ -51,24 +49,24 @@ public class UserInfoController {
...
@@ -51,24 +49,24 @@ public class UserInfoController {
}
}
@
RequestMapping
(
value
=
"/user"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/user"
)
public
UserInfo
getCurrentUserName
()
{
public
UserInfo
getCurrentUserName
()
{
return
userInfoHolder
.
getUser
();
return
userInfoHolder
.
getUser
();
}
}
@
RequestMapping
(
value
=
"/user/logout"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/user/logout"
)
public
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
void
logout
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
logoutHandler
.
logout
(
request
,
response
);
logoutHandler
.
logout
(
request
,
response
);
}
}
@
RequestMapping
(
value
=
"/users"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/users"
)
public
List
<
UserInfo
>
searchUsersByKeyword
(
@RequestParam
(
value
=
"keyword"
)
String
keyword
,
public
List
<
UserInfo
>
searchUsersByKeyword
(
@RequestParam
(
value
=
"keyword"
)
String
keyword
,
@RequestParam
(
value
=
"offset"
,
defaultValue
=
"0"
)
int
offset
,
@RequestParam
(
value
=
"offset"
,
defaultValue
=
"0"
)
int
offset
,
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
int
limit
)
{
@RequestParam
(
value
=
"limit"
,
defaultValue
=
"10"
)
int
limit
)
{
return
userService
.
searchUsers
(
keyword
,
offset
,
limit
);
return
userService
.
searchUsers
(
keyword
,
offset
,
limit
);
}
}
@
RequestMapping
(
value
=
"/users/{userId}"
,
method
=
RequestMethod
.
GET
)
@
GetMapping
(
"/users/{userId}"
)
public
UserInfo
getUserByUserId
(
@PathVariable
String
userId
)
{
public
UserInfo
getUserByUserId
(
@PathVariable
String
userId
)
{
return
userService
.
findByUserId
(
userId
);
return
userService
.
findByUserId
(
userId
);
}
}
...
...
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