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
f5218b17
Commit
f5218b17
authored
Dec 12, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
link namespace show public namespace's item & refactor bean & improve log
parent
b6996c0a
Changes
29
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
1777 additions
and
1277 deletions
+1777
-1277
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
...k/apollo/adminservice/controller/NamespaceController.java
+11
-0
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
.../ctrip/framework/apollo/biz/service/NamespaceService.java
+19
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java
...ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java
+15
-14
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java
...ork/apollo/openapi/v1/controller/NamespaceController.java
+5
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
...om/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
+13
-6
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/PortalSettings.java
...ip/framework/apollo/portal/components/PortalSettings.java
+13
-7
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/RetryableRestTemplate.java
...ework/apollo/portal/components/RetryableRestTemplate.java
+13
-5
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java
...k/apollo/portal/controller/NamespaceBranchController.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
...amework/apollo/portal/controller/NamespaceController.java
+15
-6
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java
...framework/apollo/portal/controller/ReleaseController.java
+2
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java
...a/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java
+53
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java
...com/ctrip/framework/apollo/portal/entity/bo/KVEntity.java
+1
-1
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java
.../ctrip/framework/apollo/portal/entity/bo/NamespaceBO.java
+5
-56
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java
...om/ctrip/framework/apollo/portal/entity/bo/ReleaseBO.java
+3
-2
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java
...a/com/ctrip/framework/apollo/portal/entity/vo/Change.java
+1
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java
...amework/apollo/portal/entity/vo/ReleaseCompareResult.java
+1
-0
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
...amework/apollo/portal/service/NamespaceBranchService.java
+4
-4
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
...rip/framework/apollo/portal/service/NamespaceService.java
+51
-41
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
...ctrip/framework/apollo/portal/service/ReleaseService.java
+5
-5
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigNamespaceController.js
...ic/scripts/controller/config/ConfigNamespaceController.js
+3
-3
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
...ces/static/scripts/directive/namespace-panel-directive.js
+48
-6
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+18
-0
apollo-portal/src/main/resources/static/scripts/services/ReleaseService.js
.../main/resources/static/scripts/services/ReleaseService.js
+24
-0
apollo-portal/src/main/resources/static/styles/common-style.css
...-portal/src/main/resources/static/styles/common-style.css
+19
-0
apollo-portal/src/main/resources/static/views/component/namespace-panel-branch-tab.html
...es/static/views/component/namespace-panel-branch-tab.html
+521
-0
apollo-portal/src/main/resources/static/views/component/namespace-panel-header.html
...ources/static/views/component/namespace-panel-header.html
+41
-0
apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html
...es/static/views/component/namespace-panel-master-tab.html
+864
-0
apollo-portal/src/main/resources/static/views/component/namespace-panel.html
...ain/resources/static/views/component/namespace-panel.html
+4
-1109
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/NamespaceServiceTest.java
...framework/apollo/portal/service/NamespaceServiceTest.java
+3
-3
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
View file @
f5218b17
...
@@ -78,4 +78,15 @@ public class NamespaceController {
...
@@ -78,4 +78,15 @@ public class NamespaceController {
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
}
}
@RequestMapping
(
"/clusters/{clusterName}/namespaces/{namespaceName}/public"
)
public
NamespaceDTO
findPublicNamespace
(
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
Namespace
namespace
=
namespaceService
.
findPublicNamespace
(
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
throw
new
NotFoundException
(
String
.
format
(
"public namespace not found. namespace:%s"
,
namespaceName
));
}
return
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
namespace
);
}
}
}
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/NamespaceService.java
View file @
f5218b17
...
@@ -6,8 +6,10 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
...
@@ -6,8 +6,10 @@ import com.ctrip.framework.apollo.biz.entity.Namespace;
import
com.ctrip.framework.apollo.biz.repository.NamespaceRepository
;
import
com.ctrip.framework.apollo.biz.repository.NamespaceRepository
;
import
com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus
;
import
com.ctrip.framework.apollo.common.constants.NamespaceBranchStatus
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.exception.BadRequestException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.ConfigConsts
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -57,6 +59,23 @@ public class NamespaceService {
...
@@ -57,6 +59,23 @@ public class NamespaceService {
namespaceName
);
namespaceName
);
}
}
public
Namespace
findPublicNamespace
(
String
clusterName
,
String
namespaceName
)
{
AppNamespace
appNamespace
=
appNamespaceService
.
findPublicNamespaceByName
(
namespaceName
);
if
(
appNamespace
==
null
)
{
throw
new
BadRequestException
(
"namespace not exist"
);
}
String
appId
=
appNamespace
.
getAppId
();
Namespace
namespace
=
findOne
(
appId
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
namespace
=
findOne
(
appId
,
ConfigConsts
.
CLUSTER_NAME_DEFAULT
,
namespaceName
);
}
return
namespace
;
}
public
List
<
Namespace
>
findNamespaces
(
String
appId
,
String
clusterName
)
{
public
List
<
Namespace
>
findNamespaces
(
String
appId
,
String
clusterName
)
{
List
<
Namespace
>
namespaces
=
namespaceRepository
.
findByAppIdAndClusterNameOrderByIdAsc
(
appId
,
clusterName
);
List
<
Namespace
>
namespaces
=
namespaceRepository
.
findByAppIdAndClusterNameOrderByIdAsc
(
appId
,
clusterName
);
if
(
namespaces
==
null
)
{
if
(
namespaces
==
null
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/util/OpenApiBeanUtils.java
View file @
f5218b17
...
@@ -12,7 +12,8 @@ import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
...
@@ -12,7 +12,8 @@ import com.ctrip.framework.apollo.openapi.dto.OpenItemDTO;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenReleaseDTO
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.entity.bo.ItemBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -51,22 +52,22 @@ public class OpenApiBeanUtils {
...
@@ -51,22 +52,22 @@ public class OpenApiBeanUtils {
return
openReleaseDTO
;
return
openReleaseDTO
;
}
}
public
static
OpenNamespaceDTO
transformFromNamespace
VO
(
NamespaceVO
namespaceV
O
)
{
public
static
OpenNamespaceDTO
transformFromNamespace
BO
(
NamespaceBO
namespaceB
O
)
{
Preconditions
.
checkArgument
(
namespace
V
O
!=
null
);
Preconditions
.
checkArgument
(
namespace
B
O
!=
null
);
OpenNamespaceDTO
openNamespaceDTO
=
BeanUtils
.
transfrom
(
OpenNamespaceDTO
.
class
,
namespace
V
O
OpenNamespaceDTO
openNamespaceDTO
=
BeanUtils
.
transfrom
(
OpenNamespaceDTO
.
class
,
namespace
B
O
.
getBaseInfo
());
.
getBaseInfo
());
//app namespace info
//app namespace info
openNamespaceDTO
.
setFormat
(
namespace
V
O
.
getFormat
());
openNamespaceDTO
.
setFormat
(
namespace
B
O
.
getFormat
());
openNamespaceDTO
.
setComment
(
namespace
V
O
.
getComment
());
openNamespaceDTO
.
setComment
(
namespace
B
O
.
getComment
());
openNamespaceDTO
.
setPublic
(
namespace
V
O
.
isPublic
());
openNamespaceDTO
.
setPublic
(
namespace
B
O
.
isPublic
());
//items
//items
List
<
OpenItemDTO
>
items
=
new
LinkedList
<>();
List
<
OpenItemDTO
>
items
=
new
LinkedList
<>();
List
<
NamespaceVO
.
ItemVO
>
itemVOs
=
namespaceV
O
.
getItems
();
List
<
ItemBO
>
itemBOs
=
namespaceB
O
.
getItems
();
if
(!
CollectionUtils
.
isEmpty
(
item
V
Os
))
{
if
(!
CollectionUtils
.
isEmpty
(
item
B
Os
))
{
items
.
addAll
(
item
VOs
.
stream
().
map
(
itemVO
->
transformFromItemDTO
(
itemV
O
.
getItem
())).
collect
items
.
addAll
(
item
BOs
.
stream
().
map
(
itemBO
->
transformFromItemDTO
(
itemB
O
.
getItem
())).
collect
(
Collectors
.
toList
()));
(
Collectors
.
toList
()));
}
}
openNamespaceDTO
.
setItems
(
items
);
openNamespaceDTO
.
setItems
(
items
);
...
@@ -74,14 +75,14 @@ public class OpenApiBeanUtils {
...
@@ -74,14 +75,14 @@ public class OpenApiBeanUtils {
}
}
public
static
List
<
OpenNamespaceDTO
>
batchTransformFromNamespace
VOs
(
List
<
NamespaceV
O
>
public
static
List
<
OpenNamespaceDTO
>
batchTransformFromNamespace
BOs
(
List
<
NamespaceB
O
>
namespace
V
Os
)
{
namespace
B
Os
)
{
if
(
CollectionUtils
.
isEmpty
(
namespace
V
Os
))
{
if
(
CollectionUtils
.
isEmpty
(
namespace
B
Os
))
{
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
List
<
OpenNamespaceDTO
>
openNamespaceDTOs
=
List
<
OpenNamespaceDTO
>
openNamespaceDTOs
=
namespace
VOs
.
stream
().
map
(
OpenApiBeanUtils:
:
transformFromNamespaceV
O
)
namespace
BOs
.
stream
().
map
(
OpenApiBeanUtils:
:
transformFromNamespaceB
O
)
.
collect
(
Collectors
.
toCollection
(
LinkedList:
:
new
));
.
collect
(
Collectors
.
toCollection
(
LinkedList:
:
new
));
return
openNamespaceDTOs
;
return
openNamespaceDTOs
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/openapi/v1/controller/NamespaceController.java
View file @
f5218b17
...
@@ -7,7 +7,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
...
@@ -7,7 +7,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO
;
import
com.ctrip.framework.apollo.openapi.dto.OpenNamespaceLockDTO
;
import
com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils
;
import
com.ctrip.framework.apollo.openapi.util.OpenApiBeanUtils
;
import
com.ctrip.framework.apollo.portal.entity.
vo.NamespaceV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.NamespaceB
O
;
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
;
...
@@ -33,7 +33,7 @@ public class NamespaceController {
...
@@ -33,7 +33,7 @@ public class NamespaceController {
@PathVariable
String
clusterName
)
{
@PathVariable
String
clusterName
)
{
return
OpenApiBeanUtils
return
OpenApiBeanUtils
.
batchTransformFromNamespace
VOs
(
namespaceService
.
findNamespace
s
(
appId
,
Env
.
batchTransformFromNamespace
BOs
(
namespaceService
.
findNamespaceBO
s
(
appId
,
Env
.
fromString
(
env
),
clusterName
));
.
fromString
(
env
),
clusterName
));
}
}
...
@@ -41,12 +41,12 @@ public class NamespaceController {
...
@@ -41,12 +41,12 @@ public class NamespaceController {
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
)
{
Namespace
VO
namespaceVO
=
namespaceService
.
loadNamespace
(
appId
,
Env
.
fromString
Namespace
BO
namespaceBO
=
namespaceService
.
loadNamespaceBO
(
appId
,
Env
.
fromString
(
env
),
clusterName
,
namespaceName
);
(
env
),
clusterName
,
namespaceName
);
if
(
namespace
V
O
==
null
)
{
if
(
namespace
B
O
==
null
)
{
return
null
;
return
null
;
}
}
return
OpenApiBeanUtils
.
transformFromNamespace
VO
(
namespaceV
O
);
return
OpenApiBeanUtils
.
transformFromNamespace
BO
(
namespaceB
O
);
}
}
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/lock"
,
method
=
RequestMethod
.
GET
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/api/AdminServiceAPI.java
View file @
f5218b17
...
@@ -71,12 +71,16 @@ public class AdminServiceAPI {
...
@@ -71,12 +71,16 @@ public class AdminServiceAPI {
public
NamespaceDTO
loadNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
public
NamespaceDTO
loadNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
String
namespaceName
)
{
NamespaceDTO
dto
=
return
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}"
,
restTemplate
.
get
(
env
,
"apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}"
,
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
NamespaceDTO
.
class
,
appId
,
clusterName
,
namespaceName
);
return
dto
;
}
}
public
NamespaceDTO
loadPublicNamespace
(
Env
env
,
String
clusterName
,
String
namespaceName
)
{
return
restTemplate
.
get
(
env
,
"/clusters/{clusterName}/namespaces/{namespaceName}/public"
,
NamespaceDTO
.
class
,
clusterName
,
namespaceName
);
}
public
NamespaceDTO
createNamespace
(
Env
env
,
NamespaceDTO
namespace
)
{
public
NamespaceDTO
createNamespace
(
Env
env
,
NamespaceDTO
namespace
)
{
return
restTemplate
return
restTemplate
...
@@ -378,23 +382,26 @@ public class AdminServiceAPI {
...
@@ -378,23 +382,26 @@ public class AdminServiceAPI {
public
static
class
ReleaseHistoryAPI
extends
API
{
public
static
class
ReleaseHistoryAPI
extends
API
{
private
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>
type
=
private
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>
type
=
new
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>()
{};
new
ParameterizedTypeReference
<
PageDTO
<
ReleaseHistoryDTO
>>()
{
};
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
public
PageDTO
<
ReleaseHistoryDTO
>
findReleaseHistoriesByNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
String
namespaceName
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
return
restTemplate
.
get
(
env
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories?page={page}&size={size}"
,
"/apps/{appId}/clusters/{clusterName}/namespaces/{namespaceName}/releases/histories?page={page}&size={size}"
,
type
,
appId
,
clusterName
,
namespaceName
,
page
,
size
).
getBody
();
type
,
appId
,
clusterName
,
namespaceName
,
page
,
size
).
getBody
();
}
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByReleaseIdAndOperation
(
Env
env
,
long
releaseId
,
int
operation
,
int
page
,
int
size
)
{
public
PageDTO
<
ReleaseHistoryDTO
>
findByReleaseIdAndOperation
(
Env
env
,
long
releaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
return
restTemplate
.
get
(
env
,
"/releases/histories/by_release_id_and_operation?releaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
"/releases/histories/by_release_id_and_operation?releaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
releaseId
,
operation
,
page
,
size
).
getBody
();
type
,
releaseId
,
operation
,
page
,
size
).
getBody
();
}
}
public
PageDTO
<
ReleaseHistoryDTO
>
findByPreviousReleaseIdAndOperation
(
Env
env
,
long
previousReleaseId
,
int
operation
,
int
page
,
int
size
)
{
public
PageDTO
<
ReleaseHistoryDTO
>
findByPreviousReleaseIdAndOperation
(
Env
env
,
long
previousReleaseId
,
int
operation
,
int
page
,
int
size
)
{
return
restTemplate
.
get
(
env
,
return
restTemplate
.
get
(
env
,
"/releases/histories/by_previous_release_id_and_operation?previousReleaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
"/releases/histories/by_previous_release_id_and_operation?previousReleaseId={releaseId}&operation={operation}&page={page}&size={size}"
,
type
,
previousReleaseId
,
operation
,
page
,
size
).
getBody
();
type
,
previousReleaseId
,
operation
,
page
,
size
).
getBody
();
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/PortalSettings.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
components
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
components
;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.core.utils.ApolloThreadFactory
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
...
@@ -110,13 +111,15 @@ public class PortalSettings {
...
@@ -110,13 +111,15 @@ public class PortalSettings {
logger
.
info
(
"Env revived because env health check success. env: {}"
,
env
);
logger
.
info
(
"Env revived because env health check success. env: {}"
,
env
);
}
}
}
else
{
}
else
{
logger
.
warn
(
"Env health check failed, maybe because of admin server down. env: {}"
,
env
);
logger
.
error
(
"Env health check failed, maybe because of admin server down. env: {}, meta server address: {}"
,
env
,
MetaDomainConsts
.
getDomain
(
env
));
handleEnvDown
(
env
);
handleEnvDown
(
env
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
warn
(
"Env health check failed, maybe because of meta server down "
logger
.
error
(
"Env health check failed, maybe because of meta server down "
+
"or config error meta server address. env: {}"
,
env
);
+
"or configure wrong meta server address. env: {}, meta server address: {}"
,
env
,
MetaDomainConsts
.
getDomain
(
env
),
e
);
handleEnvDown
(
env
);
handleEnvDown
(
env
);
}
}
}
}
...
@@ -133,15 +136,18 @@ public class PortalSettings {
...
@@ -133,15 +136,18 @@ public class PortalSettings {
healthCheckFailedCounter
.
put
(
env
,
++
failedTimes
);
healthCheckFailedCounter
.
put
(
env
,
++
failedTimes
);
if
(!
envStatusMark
.
get
(
env
))
{
if
(!
envStatusMark
.
get
(
env
))
{
logger
.
error
(
"Env is down. env: {}, failed times: {}"
,
env
,
failedTimes
);
logger
.
error
(
"Env is down. env: {}, failed times: {}, meta server address: {}"
,
env
,
failedTimes
,
MetaDomainConsts
.
getDomain
(
env
));
}
else
{
}
else
{
if
(
failedTimes
>=
ENV_DOWN_THRESHOLD
)
{
if
(
failedTimes
>=
ENV_DOWN_THRESHOLD
)
{
envStatusMark
.
put
(
env
,
false
);
envStatusMark
.
put
(
env
,
false
);
logger
.
error
(
"Env is down because health check failed for {} times, "
logger
.
error
(
"Env is down because health check failed for {} times, "
+
"which equals to down threshold. env: {}"
,
ENV_DOWN_THRESHOLD
,
env
);
+
"which equals to down threshold. env: {}, meta server address: {}"
,
ENV_DOWN_THRESHOLD
,
env
,
MetaDomainConsts
.
getDomain
(
env
));
}
else
{
}
else
{
logger
.
warn
(
"Env health check failed for {} times which less than down threshold. down threshold:{}, env: {}"
,
logger
.
error
(
failedTimes
,
ENV_DOWN_THRESHOLD
,
env
);
"Env health check failed for {} times which less than down threshold. down threshold:{}, env: {}, meta server address: {}"
,
failedTimes
,
ENV_DOWN_THRESHOLD
,
env
,
MetaDomainConsts
.
getDomain
(
env
));
}
}
}
}
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/components/RetryableRestTemplate.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
components
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
components
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.common.exception.ServiceException
;
import
com.ctrip.framework.apollo.core.MetaDomainConsts
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.dto.ServiceDTO
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
...
@@ -109,7 +110,9 @@ public class RetryableRestTemplate {
...
@@ -109,7 +110,9 @@ public class RetryableRestTemplate {
}
}
//all admin server down
//all admin server down
ServiceException
e
=
new
ServiceException
(
"No available admin service"
);
ServiceException
e
=
new
ServiceException
(
String
.
format
(
"Admin servers are unresponsive. meta server address: %s, admin servers: %s"
,
MetaDomainConsts
.
getDomain
(
env
),
services
));
ct
.
setStatus
(
e
);
ct
.
setStatus
(
e
);
ct
.
complete
();
ct
.
complete
();
throw
e
;
throw
e
;
...
@@ -138,9 +141,9 @@ public class RetryableRestTemplate {
...
@@ -138,9 +141,9 @@ public class RetryableRestTemplate {
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
logger
.
error
(
"Http request failed, uri: {}, method: {}"
,
uri
,
HttpMethod
.
GET
,
t
);
logger
.
error
(
"Http request failed, uri: {}, method: {}"
,
uri
,
HttpMethod
.
GET
,
t
);
Tracer
.
logError
(
t
);
Tracer
.
logError
(
t
);
if
(
canRetry
(
t
,
HttpMethod
.
GET
)){
if
(
canRetry
(
t
,
HttpMethod
.
GET
))
{
Tracer
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
Tracer
.
logEvent
(
CatEventType
.
API_RETRY
,
uri
);
}
else
{
// biz exception rethrow
}
else
{
// biz exception rethrow
ct
.
setStatus
(
t
);
ct
.
setStatus
(
t
);
ct
.
complete
();
ct
.
complete
();
throw
t
;
throw
t
;
...
@@ -150,7 +153,9 @@ public class RetryableRestTemplate {
...
@@ -150,7 +153,9 @@ public class RetryableRestTemplate {
}
}
//all admin server down
//all admin server down
ServiceException
e
=
new
ServiceException
(
"No available admin service"
);
ServiceException
e
=
new
ServiceException
(
String
.
format
(
"Admin servers are unresponsive. meta server address: %s, admin servers: %s"
,
MetaDomainConsts
.
getDomain
(
env
),
services
));
ct
.
setStatus
(
e
);
ct
.
setStatus
(
e
);
ct
.
complete
();
ct
.
complete
();
throw
e
;
throw
e
;
...
@@ -162,7 +167,10 @@ public class RetryableRestTemplate {
...
@@ -162,7 +167,10 @@ public class RetryableRestTemplate {
List
<
ServiceDTO
>
services
=
adminServiceAddressLocator
.
getServiceList
(
env
);
List
<
ServiceDTO
>
services
=
adminServiceAddressLocator
.
getServiceList
(
env
);
if
(
CollectionUtils
.
isEmpty
(
services
))
{
if
(
CollectionUtils
.
isEmpty
(
services
))
{
ServiceException
e
=
new
ServiceException
(
"No available admin service"
);
ServiceException
e
=
new
ServiceException
(
String
.
format
(
"No available admin server."
+
" Maybe because of meta server down or all admin server down. "
+
"Meta server address: %s"
,
MetaDomainConsts
.
getDomain
(
env
)));
ct
.
setStatus
(
e
);
ct
.
setStatus
(
e
);
ct
.
complete
();
ct
.
complete
();
throw
e
;
throw
e
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceBranchController.java
View file @
f5218b17
...
@@ -6,7 +6,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
...
@@ -6,7 +6,7 @@ import com.ctrip.framework.apollo.common.dto.ReleaseDTO;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
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.NamespaceV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.NamespaceB
O
;
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
;
...
@@ -35,7 +35,7 @@ public class NamespaceBranchController {
...
@@ -35,7 +35,7 @@ public class NamespaceBranchController {
private
ApplicationEventPublisher
publisher
;
private
ApplicationEventPublisher
publisher
;
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/branches"
)
public
Namespace
V
O
findBranch
(
@PathVariable
String
appId
,
public
Namespace
B
O
findBranch
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
namespaceName
)
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/NamespaceController.java
View file @
f5218b17
...
@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
...
@@ -13,7 +13,7 @@ import com.ctrip.framework.apollo.core.enums.Env;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.constant.RoleType
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.model.NamespaceCreationModel
;
import
com.ctrip.framework.apollo.portal.entity.
vo.NamespaceV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.NamespaceB
O
;
import
com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent
;
import
com.ctrip.framework.apollo.portal.listener.AppNamespaceCreationEvent
;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.portal.service.AppNamespaceService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
import
com.ctrip.framework.apollo.portal.service.AppService
;
...
@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -35,6 +35,7 @@ import org.springframework.web.bind.annotation.PathVariable;
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.RequestMethod
;
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.List
;
...
@@ -67,17 +68,25 @@ public class NamespaceController {
...
@@ -67,17 +68,25 @@ public class NamespaceController {
}
}
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces"
)
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces"
)
public
List
<
Namespace
V
O
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
List
<
Namespace
B
O
>
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
)
{
@PathVariable
String
clusterName
)
{
return
namespaceService
.
findNamespaces
(
appId
,
Env
.
valueOf
(
env
),
clusterName
);
return
namespaceService
.
findNamespace
BO
s
(
appId
,
Env
.
valueOf
(
env
),
clusterName
);
}
}
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
@RequestMapping
(
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName:.+}"
)
public
Namespace
VO
findNamespaces
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
public
Namespace
BO
findNamespace
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
)
{
return
namespaceService
.
loadNamespace
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
return
namespaceService
.
loadNamespaceBO
(
appId
,
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
@RequestMapping
(
"/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/public"
)
public
NamespaceBO
findPublicNamespace
(
@PathVariable
String
env
,
@PathVariable
String
namespaceName
,
@PathVariable
String
clusterName
)
{
return
namespaceService
.
loadPublicNamespaceBO
(
Env
.
valueOf
(
env
),
clusterName
,
namespaceName
);
}
}
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateNamespacePermission(#appId)"
)
@PreAuthorize
(
value
=
"@permissionValidator.hasCreateNamespacePermission(#appId)"
)
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/controller/ReleaseController.java
View file @
f5218b17
...
@@ -5,7 +5,7 @@ import com.ctrip.framework.apollo.common.utils.RequestPrecondition;
...
@@ -5,7 +5,7 @@ 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.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.
vo.ReleaseV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.ReleaseB
O
;
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
;
...
@@ -89,7 +89,7 @@ public class ReleaseController {
...
@@ -89,7 +89,7 @@ public class ReleaseController {
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
)
@RequestMapping
(
value
=
"/apps/{appId}/envs/{env}/clusters/{clusterName}/namespaces/{namespaceName}/releases/all"
)
public
List
<
Release
V
O
>
findAllReleases
(
@PathVariable
String
appId
,
public
List
<
Release
B
O
>
findAllReleases
(
@PathVariable
String
appId
,
@PathVariable
String
env
,
@PathVariable
String
env
,
@PathVariable
String
clusterName
,
@PathVariable
String
clusterName
,
@PathVariable
String
namespaceName
,
@PathVariable
String
namespaceName
,
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/bo/ItemBO.java
0 → 100644
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
bo
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
public
class
ItemBO
{
private
ItemDTO
item
;
private
boolean
isModified
;
private
boolean
isDeleted
;
private
String
oldValue
;
private
String
newValue
;
public
ItemDTO
getItem
()
{
return
item
;
}
public
void
setItem
(
ItemDTO
item
)
{
this
.
item
=
item
;
}
public
boolean
isDeleted
()
{
return
isDeleted
;
}
public
void
setDeleted
(
boolean
deleted
)
{
isDeleted
=
deleted
;
}
public
boolean
isModified
()
{
return
isModified
;
}
public
void
setModified
(
boolean
isModified
)
{
this
.
isModified
=
isModified
;
}
public
String
getOldValue
()
{
return
oldValue
;
}
public
void
setOldValue
(
String
oldValue
)
{
this
.
oldValue
=
oldValue
;
}
public
String
getNewValue
()
{
return
newValue
;
}
public
void
setNewValue
(
String
newValue
)
{
this
.
newValue
=
newValue
;
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
v
o/KVEntity.java
→
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
b
o/KVEntity.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
v
o
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
b
o
;
public
class
KVEntity
{
public
class
KVEntity
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
vo/NamespaceV
O.java
→
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
bo/NamespaceB
O.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
v
o
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
b
o
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
java.util.List
;
import
java.util.List
;
public
class
Namespace
V
O
{
public
class
Namespace
B
O
{
private
NamespaceDTO
baseInfo
;
private
NamespaceDTO
baseInfo
;
private
int
itemModifiedCnt
;
private
int
itemModifiedCnt
;
private
List
<
Item
V
O
>
items
;
private
List
<
Item
B
O
>
items
;
private
String
format
;
private
String
format
;
private
boolean
isPublic
;
private
boolean
isPublic
;
private
String
parentAppId
;
private
String
parentAppId
;
...
@@ -31,11 +30,11 @@ public class NamespaceVO {
...
@@ -31,11 +30,11 @@ public class NamespaceVO {
this
.
itemModifiedCnt
=
itemModifiedCnt
;
this
.
itemModifiedCnt
=
itemModifiedCnt
;
}
}
public
List
<
Item
V
O
>
getItems
()
{
public
List
<
Item
B
O
>
getItems
()
{
return
items
;
return
items
;
}
}
public
void
setItems
(
List
<
Item
V
O
>
items
)
{
public
void
setItems
(
List
<
Item
B
O
>
items
)
{
this
.
items
=
items
;
this
.
items
=
items
;
}
}
...
@@ -71,54 +70,4 @@ public class NamespaceVO {
...
@@ -71,54 +70,4 @@ public class NamespaceVO {
this
.
comment
=
comment
;
this
.
comment
=
comment
;
}
}
public
static
class
ItemVO
{
private
ItemDTO
item
;
private
boolean
isModified
;
private
boolean
isDeleted
;
private
String
oldValue
;
private
String
newValue
;
public
ItemDTO
getItem
()
{
return
item
;
}
public
void
setItem
(
ItemDTO
item
)
{
this
.
item
=
item
;
}
public
boolean
isDeleted
()
{
return
isDeleted
;
}
public
void
setDeleted
(
boolean
deleted
)
{
isDeleted
=
deleted
;
}
public
boolean
isModified
()
{
return
isModified
;
}
public
void
setModified
(
boolean
isModified
)
{
this
.
isModified
=
isModified
;
}
public
String
getOldValue
()
{
return
oldValue
;
}
public
void
setOldValue
(
String
oldValue
)
{
this
.
oldValue
=
oldValue
;
}
public
String
getNewValue
()
{
return
newValue
;
}
public
void
setNewValue
(
String
newValue
)
{
this
.
newValue
=
newValue
;
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
vo/ReleaseV
O.java
→
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/
bo/ReleaseB
O.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
v
o
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
b
o
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.portal.entity.bo.KVEntity
;
import
java.util.Set
;
import
java.util.Set
;
public
class
Release
V
O
{
public
class
Release
B
O
{
private
ReleaseDTO
baseInfo
;
private
ReleaseDTO
baseInfo
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/Change.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
import
com.ctrip.framework.apollo.common.entity.EntityPair
;
import
com.ctrip.framework.apollo.common.entity.EntityPair
;
import
com.ctrip.framework.apollo.portal.entity.bo.KVEntity
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
public
class
Change
{
public
class
Change
{
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/entity/vo/ReleaseCompareResult.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
entity
.
vo
;
import
com.ctrip.framework.apollo.common.entity.EntityPair
;
import
com.ctrip.framework.apollo.common.entity.EntityPair
;
import
com.ctrip.framework.apollo.portal.entity.bo.KVEntity
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
...
...
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceBranchService.java
View file @
f5218b17
...
@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
...
@@ -11,7 +11,7 @@ import com.ctrip.framework.apollo.portal.api.AdminServiceAPI;
import
com.ctrip.framework.apollo.portal.components.ItemsComparator
;
import
com.ctrip.framework.apollo.portal.components.ItemsComparator
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.components.PermissionValidator
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.
vo.NamespaceV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.NamespaceB
O
;
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
;
...
@@ -100,7 +100,7 @@ public class NamespaceBranchService {
...
@@ -100,7 +100,7 @@ public class NamespaceBranchService {
private
ItemChangeSets
calculateBranchChangeSet
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
private
ItemChangeSets
calculateBranchChangeSet
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
String
branchName
)
{
String
branchName
)
{
Namespace
VO
parentNamespace
=
namespaceService
.
loadNamespace
(
appId
,
env
,
clusterName
,
namespaceName
);
Namespace
BO
parentNamespace
=
namespaceService
.
loadNamespaceBO
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
parentNamespace
==
null
)
{
if
(
parentNamespace
==
null
)
{
throw
new
BadRequestException
(
"base namespace not existed"
);
throw
new
BadRequestException
(
"base namespace not existed"
);
...
@@ -125,12 +125,12 @@ public class NamespaceBranchService {
...
@@ -125,12 +125,12 @@ public class NamespaceBranchService {
return
namespaceBranchAPI
.
findBranch
(
appId
,
env
,
clusterName
,
namespaceName
);
return
namespaceBranchAPI
.
findBranch
(
appId
,
env
,
clusterName
,
namespaceName
);
}
}
public
Namespace
V
O
findBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
Namespace
B
O
findBranch
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
NamespaceDTO
namespaceDTO
=
findBranchBaseInfo
(
appId
,
env
,
clusterName
,
namespaceName
);
NamespaceDTO
namespaceDTO
=
findBranchBaseInfo
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
namespaceDTO
==
null
)
{
if
(
namespaceDTO
==
null
)
{
return
null
;
return
null
;
}
}
return
namespaceService
.
loadNamespace
(
appId
,
env
,
namespaceDTO
.
getClusterName
(),
namespaceName
);
return
namespaceService
.
loadNamespace
BO
(
appId
,
env
,
namespaceDTO
.
getClusterName
(),
namespaceName
);
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/NamespaceService.java
View file @
f5218b17
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
package
com
.
ctrip
.
framework
.
apollo
.
portal
.
service
;
import
com.google.gson.Gson
;
import
com.google.gson.Gson
;
import
com.google.gson.reflect.TypeToken
;
import
com.ctrip.framework.apollo.common.constants.GsonType
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.ItemDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.NamespaceDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.dto.ReleaseDTO
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
import
com.ctrip.framework.apollo.common.entity.AppNamespace
;
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.core.ConfigConsts
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.ConfigFileFormat
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.core.utils.StringUtils
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.entity.vo.NamespaceVO
;
import
com.ctrip.framework.apollo.portal.entity.bo.ItemBO
;
import
com.ctrip.framework.apollo.portal.entity.bo.NamespaceBO
;
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
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.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.client.HttpClientErrorException
;
import
java.lang.reflect.Type
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.LinkedList
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -35,8 +38,6 @@ public class NamespaceService {
...
@@ -35,8 +38,6 @@ public class NamespaceService {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
NamespaceService
.
class
);
private
Logger
logger
=
LoggerFactory
.
getLogger
(
NamespaceService
.
class
);
private
Gson
gson
=
new
Gson
();
private
Gson
gson
=
new
Gson
();
private
static
Type
mapType
=
new
TypeToken
<
Map
<
String
,
String
>>()
{
}.
getType
();
@Autowired
@Autowired
private
UserInfoHolder
userInfoHolder
;
private
UserInfoHolder
userInfoHolder
;
...
@@ -58,8 +59,8 @@ public class NamespaceService {
...
@@ -58,8 +59,8 @@ public class NamespaceService {
NamespaceDTO
createdNamespace
=
namespaceAPI
.
createNamespace
(
env
,
namespace
);
NamespaceDTO
createdNamespace
=
namespaceAPI
.
createNamespace
(
env
,
namespace
);
Tracer
.
logEvent
(
CatEventType
.
CREATE_NAMESPACE
,
Tracer
.
logEvent
(
CatEventType
.
CREATE_NAMESPACE
,
String
.
format
(
"%s+%s+%s+%s"
,
namespace
.
getAppId
(),
env
,
namespace
.
getClusterName
(),
String
.
format
(
"%s+%s+%s+%s"
,
namespace
.
getAppId
(),
env
,
namespace
.
getClusterName
(),
namespace
.
getNamespaceName
()));
namespace
.
getNamespaceName
()));
return
createdNamespace
;
return
createdNamespace
;
}
}
...
@@ -68,7 +69,7 @@ public class NamespaceService {
...
@@ -68,7 +69,7 @@ public class NamespaceService {
public
void
deleteNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
void
deleteNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
AppNamespace
appNamespace
=
appNamespaceService
.
findByAppIdAndName
(
appId
,
namespaceName
);
if
(
appNamespace
!=
null
&&
!
appNamespace
.
isPublic
()){
if
(
appNamespace
!=
null
&&
!
appNamespace
.
isPublic
())
{
throw
new
BadRequestException
(
"private namespace can not be deleted"
);
throw
new
BadRequestException
(
"private namespace can not be deleted"
);
}
}
...
@@ -89,20 +90,20 @@ public class NamespaceService {
...
@@ -89,20 +90,20 @@ public class NamespaceService {
/**
/**
* load cluster all namespace info with items
* load cluster all namespace info with items
*/
*/
public
List
<
Namespace
VO
>
findNamespace
s
(
String
appId
,
Env
env
,
String
clusterName
)
{
public
List
<
Namespace
BO
>
findNamespaceBO
s
(
String
appId
,
Env
env
,
String
clusterName
)
{
List
<
NamespaceDTO
>
namespaces
=
namespaceAPI
.
findNamespaceByCluster
(
appId
,
env
,
clusterName
);
List
<
NamespaceDTO
>
namespaces
=
namespaceAPI
.
findNamespaceByCluster
(
appId
,
env
,
clusterName
);
if
(
namespaces
==
null
||
namespaces
.
size
()
==
0
)
{
if
(
namespaces
==
null
||
namespaces
.
size
()
==
0
)
{
throw
new
BadRequestException
(
"namespaces not exist"
);
throw
new
BadRequestException
(
"namespaces not exist"
);
}
}
List
<
Namespace
VO
>
namespaceV
Os
=
new
LinkedList
<>();
List
<
Namespace
BO
>
namespaceB
Os
=
new
LinkedList
<>();
for
(
NamespaceDTO
namespace
:
namespaces
)
{
for
(
NamespaceDTO
namespace
:
namespaces
)
{
Namespace
VO
namespaceV
O
=
null
;
Namespace
BO
namesapceB
O
=
null
;
try
{
try
{
names
paceVO
=
parseNamespace
(
appId
,
env
,
clusterName
,
namespace
);
names
apceBO
=
transformNamespace2BO
(
appId
,
env
,
clusterName
,
namespace
);
namespace
VOs
.
add
(
namespaceV
O
);
namespace
BOs
.
add
(
namesapceB
O
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}"
,
logger
.
error
(
"parse namespace error. app id:{}, env:{}, clusterName:{}, namespace:{}"
,
appId
,
env
,
clusterName
,
namespace
.
getNamespaceName
(),
e
);
appId
,
env
,
clusterName
,
namespace
.
getNamespaceName
(),
e
);
...
@@ -110,25 +111,34 @@ public class NamespaceService {
...
@@ -110,25 +111,34 @@ public class NamespaceService {
}
}
}
}
return
namespace
V
Os
;
return
namespace
B
Os
;
}
}
public
Namespace
VO
loadNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
public
Namespace
BO
loadNamespaceBO
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
)
{
NamespaceDTO
namespace
=
namespaceAPI
.
loadNamespace
(
appId
,
env
,
clusterName
,
namespaceName
);
NamespaceDTO
namespace
=
namespaceAPI
.
loadNamespace
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
namespace
==
null
)
{
if
(
namespace
==
null
)
{
throw
new
BadRequestException
(
"namespaces not exist"
);
throw
new
BadRequestException
(
"namespaces not exist"
);
}
}
return
parseNamespace
(
appId
,
env
,
clusterName
,
namespace
);
return
transformNamespace2BO
(
appId
,
env
,
clusterName
,
namespace
);
}
}
private
NamespaceVO
parseNamespace
(
String
appId
,
Env
env
,
String
clusterName
,
NamespaceDTO
namespace
)
{
public
NamespaceBO
loadPublicNamespaceBO
(
Env
env
,
String
clusterName
,
String
namespaceName
)
{
NamespaceVO
namespaceVO
=
new
NamespaceVO
();
NamespaceDTO
namespace
=
namespaceAPI
.
loadPublicNamespace
(
env
,
clusterName
,
namespaceName
);
namespaceVO
.
setBaseInfo
(
namespace
);
fillAppNamespaceProperties
(
namespaceVO
);
String
appId
=
namespace
.
getAppId
();
String
actualClusterName
=
namespace
.
getClusterName
();
List
<
NamespaceVO
.
ItemVO
>
itemVos
=
new
LinkedList
<>();
return
transformNamespace2BO
(
appId
,
env
,
actualClusterName
,
namespace
);
namespaceVO
.
setItems
(
itemVos
);
}
private
NamespaceBO
transformNamespace2BO
(
String
appId
,
Env
env
,
String
clusterName
,
NamespaceDTO
namespace
)
{
NamespaceBO
namespaceBO
=
new
NamespaceBO
();
namespaceBO
.
setBaseInfo
(
namespace
);
fillAppNamespaceProperties
(
namespaceBO
);
List
<
ItemBO
>
itemBOs
=
new
LinkedList
<>();
namespaceBO
.
setItems
(
itemBOs
);
String
namespaceName
=
namespace
.
getNamespaceName
();
String
namespaceName
=
namespace
.
getNamespaceName
();
...
@@ -137,7 +147,7 @@ public class NamespaceService {
...
@@ -137,7 +147,7 @@ public class NamespaceService {
Map
<
String
,
String
>
releaseItems
=
new
HashMap
<>();
Map
<
String
,
String
>
releaseItems
=
new
HashMap
<>();
latestRelease
=
releaseService
.
loadLatestRelease
(
appId
,
env
,
clusterName
,
namespaceName
);
latestRelease
=
releaseService
.
loadLatestRelease
(
appId
,
env
,
clusterName
,
namespaceName
);
if
(
latestRelease
!=
null
)
{
if
(
latestRelease
!=
null
)
{
releaseItems
=
gson
.
fromJson
(
latestRelease
.
getConfigurations
(),
mapType
);
releaseItems
=
gson
.
fromJson
(
latestRelease
.
getConfigurations
(),
GsonType
.
CONFIG
);
}
}
//not Release config items
//not Release config items
...
@@ -145,26 +155,26 @@ public class NamespaceService {
...
@@ -145,26 +155,26 @@ public class NamespaceService {
int
modifiedItemCnt
=
0
;
int
modifiedItemCnt
=
0
;
for
(
ItemDTO
itemDTO
:
items
)
{
for
(
ItemDTO
itemDTO
:
items
)
{
NamespaceVO
.
ItemVO
itemVO
=
parseItemV
O
(
itemDTO
,
releaseItems
);
ItemBO
itemBO
=
transformItem2B
O
(
itemDTO
,
releaseItems
);
if
(
item
V
O
.
isModified
())
{
if
(
item
B
O
.
isModified
())
{
modifiedItemCnt
++;
modifiedItemCnt
++;
}
}
item
Vos
.
add
(
itemV
O
);
item
BOs
.
add
(
itemB
O
);
}
}
//deleted items
//deleted items
List
<
NamespaceVO
.
ItemV
O
>
deletedItems
=
parseDeletedItems
(
items
,
releaseItems
);
List
<
ItemB
O
>
deletedItems
=
parseDeletedItems
(
items
,
releaseItems
);
item
Vo
s
.
addAll
(
deletedItems
);
item
BO
s
.
addAll
(
deletedItems
);
modifiedItemCnt
+=
deletedItems
.
size
();
modifiedItemCnt
+=
deletedItems
.
size
();
namespace
V
O
.
setItemModifiedCnt
(
modifiedItemCnt
);
namespace
B
O
.
setItemModifiedCnt
(
modifiedItemCnt
);
return
namespace
V
O
;
return
namespace
B
O
;
}
}
private
void
fillAppNamespaceProperties
(
Namespace
V
O
namespace
)
{
private
void
fillAppNamespaceProperties
(
Namespace
B
O
namespace
)
{
NamespaceDTO
namespaceDTO
=
namespace
.
getBaseInfo
();
NamespaceDTO
namespaceDTO
=
namespace
.
getBaseInfo
();
//先从当前appId下面找,包含私有的和公共的
//先从当前appId下面找,包含私有的和公共的
...
@@ -190,14 +200,14 @@ public class NamespaceService {
...
@@ -190,14 +200,14 @@ public class NamespaceService {
namespace
.
setPublic
(
isPublic
);
namespace
.
setPublic
(
isPublic
);
}
}
private
List
<
NamespaceVO
.
ItemV
O
>
parseDeletedItems
(
List
<
ItemDTO
>
newItems
,
Map
<
String
,
String
>
releaseItems
)
{
private
List
<
ItemB
O
>
parseDeletedItems
(
List
<
ItemDTO
>
newItems
,
Map
<
String
,
String
>
releaseItems
)
{
Map
<
String
,
ItemDTO
>
newItemMap
=
BeanUtils
.
mapByKey
(
"key"
,
newItems
);
Map
<
String
,
ItemDTO
>
newItemMap
=
BeanUtils
.
mapByKey
(
"key"
,
newItems
);
List
<
NamespaceVO
.
ItemV
O
>
deletedItems
=
new
LinkedList
<>();
List
<
ItemB
O
>
deletedItems
=
new
LinkedList
<>();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
releaseItems
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
releaseItems
.
entrySet
())
{
String
key
=
entry
.
getKey
();
String
key
=
entry
.
getKey
();
if
(
newItemMap
.
get
(
key
)
==
null
)
{
if
(
newItemMap
.
get
(
key
)
==
null
)
{
NamespaceVO
.
ItemVO
deletedItem
=
new
NamespaceVO
.
ItemV
O
();
ItemBO
deletedItem
=
new
ItemB
O
();
deletedItem
.
setDeleted
(
true
);
deletedItem
.
setDeleted
(
true
);
ItemDTO
deletedItemDto
=
new
ItemDTO
();
ItemDTO
deletedItemDto
=
new
ItemDTO
();
...
@@ -215,19 +225,19 @@ public class NamespaceService {
...
@@ -215,19 +225,19 @@ public class NamespaceService {
return
deletedItems
;
return
deletedItems
;
}
}
private
NamespaceVO
.
ItemVO
parseItemV
O
(
ItemDTO
itemDTO
,
Map
<
String
,
String
>
releaseItems
)
{
private
ItemBO
transformItem2B
O
(
ItemDTO
itemDTO
,
Map
<
String
,
String
>
releaseItems
)
{
String
key
=
itemDTO
.
getKey
();
String
key
=
itemDTO
.
getKey
();
NamespaceVO
.
ItemVO
itemVO
=
new
NamespaceVO
.
ItemV
O
();
ItemBO
itemBO
=
new
ItemB
O
();
item
V
O
.
setItem
(
itemDTO
);
item
B
O
.
setItem
(
itemDTO
);
String
newValue
=
itemDTO
.
getValue
();
String
newValue
=
itemDTO
.
getValue
();
String
oldValue
=
releaseItems
.
get
(
key
);
String
oldValue
=
releaseItems
.
get
(
key
);
//new item or modified
//new item or modified
if
(!
StringUtils
.
isEmpty
(
key
)
&&
(
oldValue
==
null
||
!
newValue
.
equals
(
oldValue
)))
{
if
(!
StringUtils
.
isEmpty
(
key
)
&&
(
oldValue
==
null
||
!
newValue
.
equals
(
oldValue
)))
{
item
V
O
.
setModified
(
true
);
item
B
O
.
setModified
(
true
);
item
V
O
.
setOldValue
(
oldValue
==
null
?
""
:
oldValue
);
item
B
O
.
setOldValue
(
oldValue
==
null
?
""
:
oldValue
);
item
V
O
.
setNewValue
(
newValue
);
item
B
O
.
setNewValue
(
newValue
);
}
}
return
item
V
O
;
return
item
B
O
;
}
}
}
}
apollo-portal/src/main/java/com/ctrip/framework/apollo/portal/service/ReleaseService.java
View file @
f5218b17
...
@@ -11,9 +11,9 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
...
@@ -11,9 +11,9 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
import
com.ctrip.framework.apollo.portal.constant.CatEventType
;
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.
v
o.KVEntity
;
import
com.ctrip.framework.apollo.portal.entity.
b
o.KVEntity
;
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.
vo.ReleaseV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.ReleaseB
O
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
import
com.ctrip.framework.apollo.portal.enums.ChangeType
;
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
;
...
@@ -65,7 +65,7 @@ public class ReleaseService {
...
@@ -65,7 +65,7 @@ public class ReleaseService {
deleteBranch
,
changeSets
);
deleteBranch
,
changeSets
);
}
}
public
List
<
Release
V
O
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
public
List
<
Release
B
O
>
findAllReleases
(
String
appId
,
Env
env
,
String
clusterName
,
String
namespaceName
,
int
page
,
int
size
)
{
int
size
)
{
List
<
ReleaseDTO
>
releaseDTOs
=
releaseAPI
.
findAllReleases
(
appId
,
env
,
clusterName
,
namespaceName
,
page
,
size
);
List
<
ReleaseDTO
>
releaseDTOs
=
releaseAPI
.
findAllReleases
(
appId
,
env
,
clusterName
,
namespaceName
,
page
,
size
);
...
@@ -73,9 +73,9 @@ public class ReleaseService {
...
@@ -73,9 +73,9 @@ public class ReleaseService {
return
Collections
.
emptyList
();
return
Collections
.
emptyList
();
}
}
List
<
Release
V
O
>
releases
=
new
LinkedList
<>();
List
<
Release
B
O
>
releases
=
new
LinkedList
<>();
for
(
ReleaseDTO
releaseDTO
:
releaseDTOs
)
{
for
(
ReleaseDTO
releaseDTO
:
releaseDTOs
)
{
Release
VO
release
=
new
ReleaseV
O
();
Release
BO
release
=
new
ReleaseB
O
();
release
.
setBaseInfo
(
releaseDTO
);
release
.
setBaseInfo
(
releaseDTO
);
Set
<
KVEntity
>
kvEntities
=
new
LinkedHashSet
<>();
Set
<
KVEntity
>
kvEntities
=
new
LinkedHashSet
<>();
...
...
apollo-portal/src/main/resources/static/scripts/controller/config/ConfigNamespaceController.js
View file @
f5218b17
...
@@ -62,6 +62,7 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
...
@@ -62,6 +62,7 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
function
(
result
)
{
function
(
result
)
{
$scope
.
namespaces
=
result
;
$scope
.
namespaces
=
result
;
$
(
'
.config-item-container
'
).
removeClass
(
'
hide
'
);
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载配置信息出错
"
);
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载配置信息出错
"
);
...
@@ -138,10 +139,9 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
...
@@ -138,10 +139,9 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
$scope
.
item
=
_
.
clone
(
toEditItem
);
$scope
.
item
=
_
.
clone
(
toEditItem
);
if
(
namespace
.
isBranch
)
{
if
(
namespace
.
isBranch
||
namespace
.
isLinkedNamespace
)
{
var
existedItem
=
false
;
var
existedItem
=
false
;
namespace
.
items
.
forEach
(
function
(
item
)
{
namespace
.
items
.
forEach
(
function
(
item
)
{
//branch items contain the item
if
(
!
item
.
isDeleted
&&
item
.
item
.
key
==
toEditItem
.
key
)
{
if
(
!
item
.
isDeleted
&&
item
.
item
.
key
==
toEditItem
.
key
)
{
existedItem
=
true
;
existedItem
=
true
;
}
}
...
@@ -270,7 +270,7 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
...
@@ -270,7 +270,7 @@ function controller($rootScope, $scope, toastr, AppUtil, EventManager, ConfigSer
$
(
'
.config-item-container
'
).
removeClass
(
'
hide
'
);
new
Clipboard
(
'
.clipboard
'
);
new
Clipboard
(
'
.clipboard
'
);
}
}
...
...
apollo-portal/src/main/resources/static/scripts/directive/namespace-panel-directive.js
View file @
f5218b17
...
@@ -40,7 +40,6 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -40,7 +40,6 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
ALL
:
'
all
'
ALL
:
'
all
'
};
};
var
operate_branch_storage_key
=
'
OperateBranch
'
;
var
operate_branch_storage_key
=
'
OperateBranch
'
;
scope
.
switchView
=
switchView
;
scope
.
switchView
=
switchView
;
...
@@ -101,6 +100,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -101,6 +100,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
initNamespaceLock
(
namespace
);
initNamespaceLock
(
namespace
);
initNamespaceInstancesCount
(
namespace
);
initNamespaceInstancesCount
(
namespace
);
initPermission
(
namespace
);
initPermission
(
namespace
);
initLinkedNamespace
(
namespace
);
function
initNamespaceBranch
(
namespace
)
{
function
initNamespaceBranch
(
namespace
)
{
NamespaceBranchService
.
findNamespaceBranch
(
scope
.
appId
,
scope
.
env
,
NamespaceBranchService
.
findNamespaceBranch
(
scope
.
appId
,
scope
.
env
,
...
@@ -221,6 +221,44 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -221,6 +221,44 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
});
});
}
}
function
initLinkedNamespace
(
namespace
)
{
if
(
!
namespace
.
isPublic
||
!
namespace
.
isLinkedNamespace
)
{
return
;
}
//load public namespace
ConfigService
.
load_public_namespace
(
scope
.
env
,
scope
.
cluster
,
namespace
.
baseInfo
.
namespaceName
)
.
then
(
function
(
result
)
{
var
publicNamespace
=
result
;
namespace
.
publicNamespace
=
publicNamespace
;
var
linkNamespaceItemKeys
=
[];
namespace
.
items
.
forEach
(
function
(
item
)
{
var
key
=
item
.
item
.
key
;
linkNamespaceItemKeys
.
push
(
key
);
});
publicNamespace
.
viewItems
=
[];
publicNamespace
.
items
.
forEach
(
function
(
item
)
{
var
key
=
item
.
item
.
key
;
if
(
key
){
publicNamespace
.
viewItems
.
push
(
item
);
}
item
.
covered
=
linkNamespaceItemKeys
.
indexOf
(
key
)
>=
0
;
if
(
item
.
isModified
||
item
.
isDeleted
)
{
publicNamespace
.
isModified
=
true
;
}
else
if
(
key
){
publicNamespace
.
hasPublishedItem
=
true
;
}
});
});
}
function
initNamespaceViewName
(
namespace
)
{
function
initNamespaceViewName
(
namespace
)
{
//namespace view name hide suffix
//namespace view name hide suffix
namespace
.
viewName
=
namespace
.
viewName
=
...
@@ -270,7 +308,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -270,7 +308,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
switchBranch
(
operateBranchStorage
[
namespaceId
]);
switchBranch
(
operateBranchStorage
[
namespaceId
]);
}
}
}
}
function
initNamespaceInstancesCount
(
namespace
)
{
function
initNamespaceInstancesCount
(
namespace
)
{
...
@@ -497,11 +535,11 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -497,11 +535,11 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
scope
.
namespace
.
baseInfo
.
namespaceName
,
scope
.
namespace
.
baseInfo
.
namespaceName
,
branch
.
baseInfo
.
clusterName
)
branch
.
baseInfo
.
clusterName
)
.
then
(
function
(
result
)
{
.
then
(
function
(
result
)
{
if
(
result
.
appId
)
{
if
(
result
.
appId
)
{
branch
.
rules
=
result
;
branch
.
rules
=
result
;
}
}
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载灰度规则出错
"
);
toastr
.
error
(
AppUtil
.
errorMsg
(
result
),
"
加载灰度规则出错
"
);
});
});
...
@@ -684,7 +722,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -684,7 +722,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
namespace
.
itemCnt
=
itemCnt
;
namespace
.
itemCnt
=
itemCnt
;
return
result
;
return
result
;
}
}
function
toggleItemSearchInput
(
namespace
)
{
function
toggleItemSearchInput
(
namespace
)
{
namespace
.
showSearchInput
=
!
namespace
.
showSearchInput
;
namespace
.
showSearchInput
=
!
namespace
.
showSearchInput
;
}
}
...
@@ -727,7 +765,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -727,7 +765,7 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
var
parentNamespace
=
branch
.
parentNamespace
;
var
parentNamespace
=
branch
.
parentNamespace
;
if
(
!
parentNamespace
.
hasReleasePermission
)
{
if
(
!
parentNamespace
.
hasReleasePermission
)
{
AppUtil
.
showModal
(
'
#releaseNoPermissionDialog
'
);
AppUtil
.
showModal
(
'
#releaseNoPermissionDialog
'
);
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
}
else
if
(
branch
.
lockOwner
&&
scope
.
user
==
branch
.
lockOwner
)
{
AppUtil
.
showModal
(
'
#releaseDenyDialog
'
);
AppUtil
.
showModal
(
'
#releaseDenyDialog
'
);
}
else
if
(
parentNamespace
.
itemModifiedCnt
>
0
)
{
}
else
if
(
parentNamespace
.
itemModifiedCnt
>
0
)
{
AppUtil
.
showModal
(
'
#mergeAndReleaseDenyDialog
'
);
AppUtil
.
showModal
(
'
#mergeAndReleaseDenyDialog
'
);
...
@@ -741,6 +779,10 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
...
@@ -741,6 +779,10 @@ function directive($window, toastr, AppUtil, EventManager, PermissionService, Na
EventManager
.
emit
(
EventManager
.
EventType
.
PRE_ROLLBACK_NAMESPACE
,
{
namespace
:
namespace
});
EventManager
.
emit
(
EventManager
.
EventType
.
PRE_ROLLBACK_NAMESPACE
,
{
namespace
:
namespace
});
}
}
setTimeout
(
function
()
{
scope
.
namespace
.
show
=
true
;
},
200
);
}
}
}
}
}
}
...
...
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
View file @
f5218b17
...
@@ -5,6 +5,11 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
...
@@ -5,6 +5,11 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
isArray
:
false
,
isArray
:
false
,
url
:
'
/apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName
'
url
:
'
/apps/:appId/envs/:env/clusters/:clusterName/namespaces/:namespaceName
'
},
},
load_public_namespace
:
{
method
:
'
GET
'
,
isArray
:
false
,
url
:
'
/envs/:env/clusters/:clusterName/namespaces/:namespaceName/public
'
},
load_all_namespaces
:
{
load_all_namespaces
:
{
method
:
'
GET
'
,
method
:
'
GET
'
,
isArray
:
true
,
isArray
:
true
,
...
@@ -58,6 +63,19 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
...
@@ -58,6 +63,19 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
});
});
return
d
.
promise
;
return
d
.
promise
;
},
},
load_public_namespace
:
function
(
env
,
clusterName
,
namespaceName
)
{
var
d
=
$q
.
defer
();
config_source
.
load_public_namespace
({
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
},
function
(
result
)
{
d
.
resolve
(
result
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
},
load_all_namespaces
:
function
(
appId
,
env
,
clusterName
)
{
load_all_namespaces
:
function
(
appId
,
env
,
clusterName
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
config_source
.
load_all_namespaces
({
config_source
.
load_all_namespaces
({
...
...
apollo-portal/src/main/resources/static/scripts/services/ReleaseService.js
View file @
f5218b17
...
@@ -98,6 +98,29 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -98,6 +98,29 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
});
});
return
d
.
promise
;
return
d
.
promise
;
}
}
function
findLatestActiveRelease
(
appId
,
env
,
clusterName
,
namespaceName
)
{
var
d
=
$q
.
defer
();
resource
.
find_active_releases
({
appId
:
appId
,
env
:
env
,
clusterName
:
clusterName
,
namespaceName
:
namespaceName
,
page
:
0
,
size
:
1
},
function
(
result
)
{
if
(
result
&&
result
.
length
){
d
.
resolve
(
result
[
0
]);
}
d
.
resolve
(
undefined
);
},
function
(
result
)
{
d
.
reject
(
result
);
});
return
d
.
promise
;
}
function
compare
(
env
,
baseReleaseId
,
toCompareReleaseId
)
{
function
compare
(
env
,
baseReleaseId
,
toCompareReleaseId
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
...
@@ -133,6 +156,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
...
@@ -133,6 +156,7 @@ appService.service('ReleaseService', ['$resource', '$q', function ($resource, $q
grayPublish
:
createGrayRelease
,
grayPublish
:
createGrayRelease
,
findAllRelease
:
findAllReleases
,
findAllRelease
:
findAllReleases
,
findActiveReleases
:
findActiveReleases
,
findActiveReleases
:
findActiveReleases
,
findLatestActiveRelease
:
findLatestActiveRelease
,
compare
:
compare
,
compare
:
compare
,
rollback
:
rollback
rollback
:
rollback
}
}
...
...
apollo-portal/src/main/resources/static/styles/common-style.css
View file @
f5218b17
...
@@ -50,6 +50,14 @@ p, td, span {
...
@@ -50,6 +50,14 @@ p, td, span {
border
:
solid
1px
#c3c3c3
;
border
:
solid
1px
#c3c3c3
;
}
}
.padding-top-5
{
padding-top
:
5px
;
}
.border-top
{
border-top
:
1px
solid
#ddd
;
}
.active
{
.active
{
background
:
#f5f5f5
;
background
:
#f5f5f5
;
}
}
...
@@ -336,6 +344,7 @@ table th {
...
@@ -336,6 +344,7 @@ table th {
.namespace-panel
{
.namespace-panel
{
border-top
:
0
;
border-top
:
0
;
border-bottom
:
0
;
}
}
.namespace-panel
.namespace-name
{
.namespace-panel
.namespace-name
{
...
@@ -388,6 +397,10 @@ table th {
...
@@ -388,6 +397,10 @@ table th {
}
}
.namespace-panel
.no-config-panel
{
padding
:
15px
0
;
}
.namespace-panel
.history-view
{
.namespace-panel
.history-view
{
padding
:
10px
20px
;
padding
:
10px
20px
;
...
@@ -724,4 +737,10 @@ table th {
...
@@ -724,4 +737,10 @@ table th {
width
:
auto
!important
;
width
:
auto
!important
;
}
}
.search-onblur
{
background
:
#f5f5f5
;
}
.search-focus
{
background
:
#fff
;
}
apollo-portal/src/main/resources/static/views/component/namespace-panel-branch-tab.html
0 → 100644
View file @
f5218b17
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/views/component/namespace-panel-header.html
0 → 100644
View file @
f5218b17
<header
class=
"row namespace-attribute-panel"
>
<div
class=
"text-center namespace-attribute-public"
>
<span
data-tooltip=
"tooltip"
data-placement=
"bottom"
title=
"私有namespace({{namespace.baseInfo.namespaceName}})的配置只能被AppId为{{appId}}的客户端读取到"
ng-show=
"!namespace.isPublic"
>
私有
</span>
<span
data-tooltip=
"tooltip"
data-placement=
"top"
title=
"namespace({{namespace.baseInfo.namespaceName}})的配置能被任何客户端读取到"
ng-show=
"namespace.isPublic && namespace.parentAppId == namespace.baseInfo.appId"
>
公共
</span>
<span
data-tooltip=
"tooltip"
data-placement=
"top"
title=
"namespace({{namespace.baseInfo.namespaceName}})的配置将会覆盖公共namespace的配置, 且合并之后的配置只能被AppId为{{appId}}的客户端读取到"
ng-show=
"namespace.isPublic && namespace.isLinkedNamespace"
ng-click=
"goToParentAppConfigPage(namespace)"
>
关联
</span>
</div>
</header>
<!--branch nav-->
<header
class=
"panel-heading second-panel-heading"
ng-show=
"namespace.hasBranch"
>
<div
class=
"row"
>
<div
class=
"col-md-8 pull-left"
>
<ul
class=
"nav nav-tabs"
>
<li
role=
"presentation"
>
<a
ng-class=
"{'node_active': namespace.currentOperateBranch == 'master'}"
ng-click=
"switchBranch('master')"
>
<img
src=
"img/branch.png"
>
主版本
</a>
</li>
<li
role=
"presentation"
>
<a
ng-class=
"{'node_active': namespace.currentOperateBranch != 'master'}"
ng-click=
"switchBranch(namespace.branchName)"
>
<img
src=
"img/branch.png"
>
灰度版本
</a>
</li>
</ul>
</div>
</div>
</header>
apollo-portal/src/main/resources/static/views/component/namespace-panel-master-tab.html
0 → 100644
View file @
f5218b17
This diff is collapsed.
Click to expand it.
apollo-portal/src/main/resources/static/views/component/namespace-panel.html
View file @
f5218b17
This diff is collapsed.
Click to expand it.
apollo-portal/src/test/java/com/ctrip/framework/apollo/portal/service/NamespaceServiceTest.java
View file @
f5218b17
...
@@ -8,7 +8,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
...
@@ -8,7 +8,7 @@ import com.ctrip.framework.apollo.core.enums.ConfigFileFormat;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.core.enums.Env
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver
;
import
com.ctrip.framework.apollo.portal.components.txtresolver.PropertyResolver
;
import
com.ctrip.framework.apollo.portal.entity.
vo.NamespaceV
O
;
import
com.ctrip.framework.apollo.portal.entity.
bo.NamespaceB
O
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -87,9 +87,9 @@ public class NamespaceServiceTest {
...
@@ -87,9 +87,9 @@ public class NamespaceServiceTest {
when
(
releaseService
.
loadLatestRelease
(
appId
,
Env
.
DEV
,
clusterName
,
"hermes"
)).
thenReturn
(
someRelease
);
when
(
releaseService
.
loadLatestRelease
(
appId
,
Env
.
DEV
,
clusterName
,
"hermes"
)).
thenReturn
(
someRelease
);
when
(
itemService
.
findItems
(
appId
,
Env
.
DEV
,
clusterName
,
namespaceName
)).
thenReturn
(
someItems
);
when
(
itemService
.
findItems
(
appId
,
Env
.
DEV
,
clusterName
,
namespaceName
)).
thenReturn
(
someItems
);
List
<
Namespace
VO
>
namespaceVOs
=
namespaceService
.
findNamespace
s
(
appId
,
Env
.
DEV
,
clusterName
);
List
<
Namespace
BO
>
namespaceVOs
=
namespaceService
.
findNamespaceBO
s
(
appId
,
Env
.
DEV
,
clusterName
);
assertEquals
(
2
,
namespaceVOs
.
size
());
assertEquals
(
2
,
namespaceVOs
.
size
());
Namespace
V
O
namespaceVO
=
namespaceVOs
.
get
(
0
);
Namespace
B
O
namespaceVO
=
namespaceVOs
.
get
(
0
);
assertEquals
(
4
,
namespaceVO
.
getItems
().
size
());
assertEquals
(
4
,
namespaceVO
.
getItems
().
size
());
assertEquals
(
"a"
,
namespaceVO
.
getItems
().
get
(
0
).
getItem
().
getKey
());
assertEquals
(
"a"
,
namespaceVO
.
getItems
().
get
(
0
).
getItem
().
getKey
());
assertEquals
(
2
,
namespaceVO
.
getItemModifiedCnt
());
assertEquals
(
2
,
namespaceVO
.
getItemModifiedCnt
());
...
...
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