Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
apollo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openSource
apollo
Commits
cd4e4759
Commit
cd4e4759
authored
Jul 07, 2016
by
lepdou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename createOrUpdate to create
parent
b0513014
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
28 deletions
+29
-28
AppController.java
...amework/apollo/adminservice/controller/AppController.java
+11
-8
AppNamespaceController.java
...pollo/adminservice/controller/AppNamespaceController.java
+4
-4
ClusterController.java
...ork/apollo/adminservice/controller/ClusterController.java
+10
-8
NamespaceController.java
...k/apollo/adminservice/controller/NamespaceController.java
+3
-3
ItemSetService.java
...om/ctrip/framework/apollo/biz/service/ItemSetService.java
+1
-5
No files found.
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppController.java
View file @
cd4e4759
...
@@ -31,19 +31,18 @@ public class AppController {
...
@@ -31,19 +31,18 @@ public class AppController {
private
AdminService
adminService
;
private
AdminService
adminService
;
@RequestMapping
(
path
=
"/apps"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/apps"
,
method
=
RequestMethod
.
POST
)
public
AppDTO
create
OrUpdate
(
@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
));
}
}
App
entity
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
App
entity
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
App
managedEntity
=
appService
.
findOne
(
entity
.
getAppId
());
App
managedEntity
=
appService
.
findOne
(
entity
.
getAppId
());
if
(
managedEntity
!=
null
)
{
if
(
managedEntity
!=
null
)
{
BeanUtils
.
copyEntityProperties
(
entity
,
managedEntity
);
throw
new
BadRequestException
(
"app already exist."
);
entity
=
appService
.
update
(
managedEntity
);
}
else
{
entity
=
adminService
.
createNewApp
(
entity
);
}
}
entity
=
adminService
.
createNewApp
(
entity
);
dto
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
entity
);
dto
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
entity
);
return
dto
;
return
dto
;
}
}
...
@@ -51,13 +50,15 @@ public class AppController {
...
@@ -51,13 +50,15 @@ public class AppController {
@RequestMapping
(
path
=
"/apps/{appId}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
path
=
"/apps/{appId}"
,
method
=
RequestMethod
.
DELETE
)
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
)
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
if
(
entity
==
null
)
{
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
}
appService
.
delete
(
entity
.
getId
(),
operator
);
appService
.
delete
(
entity
.
getId
(),
operator
);
}
}
@RequestMapping
(
"/apps"
)
@RequestMapping
(
"/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
;
if
(
StringUtils
.
isBlank
(
name
))
{
if
(
StringUtils
.
isBlank
(
name
))
{
app
=
appService
.
findAll
(
pageable
);
app
=
appService
.
findAll
(
pageable
);
...
@@ -70,7 +71,9 @@ public class AppController {
...
@@ -70,7 +71,9 @@ public class AppController {
@RequestMapping
(
"/apps/{appId}"
)
@RequestMapping
(
"/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
)
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
if
(
app
==
null
)
{
throw
new
NotFoundException
(
"app not found for appId "
+
appId
);
}
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
return
BeanUtils
.
transfrom
(
AppDTO
.
class
,
app
);
}
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
View file @
cd4e4759
...
@@ -22,17 +22,17 @@ public class AppNamespaceController {
...
@@ -22,17 +22,17 @@ public class AppNamespaceController {
private
AppNamespaceService
appNamespaceService
;
private
AppNamespaceService
appNamespaceService
;
@RequestMapping
(
value
=
"/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/apps/{appId}/appnamespaces"
,
method
=
RequestMethod
.
POST
)
public
AppNamespaceDTO
create
OrUpdate
(
@RequestBody
AppNamespaceDTO
appNamespace
)
{
public
AppNamespaceDTO
create
(
@RequestBody
AppNamespaceDTO
appNamespace
)
{
AppNamespace
entity
=
BeanUtils
.
transfrom
(
AppNamespace
.
class
,
appNamespace
);
AppNamespace
entity
=
BeanUtils
.
transfrom
(
AppNamespace
.
class
,
appNamespace
);
AppNamespace
managedEntity
=
appNamespaceService
.
findOne
(
entity
.
getAppId
(),
entity
.
getName
());
AppNamespace
managedEntity
=
appNamespaceService
.
findOne
(
entity
.
getAppId
(),
entity
.
getName
());
if
(
managedEntity
!=
null
){
if
(
managedEntity
!=
null
)
{
throw
new
BadRequestException
(
"app namespaces already exist."
);
throw
new
BadRequestException
(
"app namespaces already exist."
);
}
else
{
entity
=
appNamespaceService
.
createAppNamespace
(
entity
,
entity
.
getDataChangeCreatedBy
());
}
}
entity
=
appNamespaceService
.
createAppNamespace
(
entity
,
entity
.
getDataChangeCreatedBy
());
return
BeanUtils
.
transfrom
(
AppNamespaceDTO
.
class
,
entity
);
return
BeanUtils
.
transfrom
(
AppNamespaceDTO
.
class
,
entity
);
}
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
View file @
cd4e4759
...
@@ -25,7 +25,7 @@ public class ClusterController {
...
@@ -25,7 +25,7 @@ public class ClusterController {
private
ClusterService
clusterService
;
private
ClusterService
clusterService
;
@RequestMapping
(
path
=
"/apps/{appId}/clusters"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/apps/{appId}/clusters"
,
method
=
RequestMethod
.
POST
)
public
ClusterDTO
create
OrUpdate
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestBody
ClusterDTO
dto
)
{
public
ClusterDTO
create
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestBody
ClusterDTO
dto
)
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getName
()))
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getName
()))
{
throw
new
BadRequestException
(
String
.
format
(
"Cluster格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
throw
new
BadRequestException
(
String
.
format
(
"Cluster格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
}
}
...
@@ -33,9 +33,8 @@ public class ClusterController {
...
@@ -33,9 +33,8 @@ public class ClusterController {
Cluster
managedEntity
=
clusterService
.
findOne
(
appId
,
entity
.
getName
());
Cluster
managedEntity
=
clusterService
.
findOne
(
appId
,
entity
.
getName
());
if
(
managedEntity
!=
null
)
{
if
(
managedEntity
!=
null
)
{
throw
new
BadRequestException
(
"cluster already exist."
);
throw
new
BadRequestException
(
"cluster already exist."
);
}
else
{
entity
=
clusterService
.
save
(
entity
);
}
}
entity
=
clusterService
.
save
(
entity
);
dto
=
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
entity
);
dto
=
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
entity
);
return
dto
;
return
dto
;
...
@@ -43,10 +42,11 @@ public class ClusterController {
...
@@ -43,10 +42,11 @@ public class ClusterController {
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
DELETE
)
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName:.+}"
,
method
=
RequestMethod
.
DELETE
)
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
)
{
Cluster
entity
=
clusterService
.
findOne
(
appId
,
clusterName
);
Cluster
entity
=
clusterService
.
findOne
(
appId
,
clusterName
);
if
(
entity
==
null
)
if
(
entity
==
null
)
{
throw
new
NotFoundException
(
"cluster not found for clusterName "
+
clusterName
);
throw
new
NotFoundException
(
"cluster not found for clusterName "
+
clusterName
);
}
clusterService
.
delete
(
entity
.
getId
(),
operator
);
clusterService
.
delete
(
entity
.
getId
(),
operator
);
}
}
...
@@ -58,15 +58,17 @@ public class ClusterController {
...
@@ -58,15 +58,17 @@ public class ClusterController {
@RequestMapping
(
"/apps/{appId}/clusters/{clusterName:.+}"
)
@RequestMapping
(
"/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
);
if
(
cluster
==
null
)
throw
new
NotFoundException
(
"cluster not found for name "
+
clusterName
);
if
(
cluster
==
null
)
{
throw
new
NotFoundException
(
"cluster not found for name "
+
clusterName
);
}
return
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
cluster
);
return
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
cluster
);
}
}
@RequestMapping
(
"/apps/{appId}/cluster/{clusterName}/unique"
)
@RequestMapping
(
"/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/NamespaceController.java
View file @
cd4e4759
...
@@ -25,7 +25,7 @@ public class NamespaceController {
...
@@ -25,7 +25,7 @@ public class NamespaceController {
private
NamespaceService
namespaceService
;
private
NamespaceService
namespaceService
;
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
path
=
"/apps/{appId}/clusters/{clusterName}/namespaces"
,
method
=
RequestMethod
.
POST
)
public
NamespaceDTO
create
OrUpdate
(
@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
()))
{
throw
new
BadRequestException
(
String
.
format
(
"Namespace格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
throw
new
BadRequestException
(
String
.
format
(
"Namespace格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
...
@@ -34,10 +34,10 @@ public class NamespaceController {
...
@@ -34,10 +34,10 @@ public class NamespaceController {
Namespace
managedEntity
=
namespaceService
.
findOne
(
appId
,
clusterName
,
entity
.
getNamespaceName
());
Namespace
managedEntity
=
namespaceService
.
findOne
(
appId
,
clusterName
,
entity
.
getNamespaceName
());
if
(
managedEntity
!=
null
)
{
if
(
managedEntity
!=
null
)
{
throw
new
BadRequestException
(
"namespace already exist."
);
throw
new
BadRequestException
(
"namespace already exist."
);
}
else
{
entity
=
namespaceService
.
save
(
entity
);
}
}
entity
=
namespaceService
.
save
(
entity
);
dto
=
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
entity
);
dto
=
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
entity
);
return
dto
;
return
dto
;
}
}
...
...
apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ItemSetService.java
View file @
cd4e4759
...
@@ -8,7 +8,6 @@ import org.springframework.util.CollectionUtils;
...
@@ -8,7 +8,6 @@ import org.springframework.util.CollectionUtils;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.entity.Item
;
import
com.ctrip.framework.apollo.biz.repository.ItemRepository
;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.biz.utils.ConfigChangeContentBuilder
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
...
@@ -20,9 +19,6 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
...
@@ -20,9 +19,6 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
public
class
ItemSetService
{
public
class
ItemSetService
{
@Autowired
@Autowired
private
ItemRepository
itemRepository
;
@Autowired
private
AuditService
auditService
;
private
AuditService
auditService
;
@Autowired
@Autowired
...
@@ -53,7 +49,7 @@ public class ItemSetService {
...
@@ -53,7 +49,7 @@ public class ItemSetService {
for
(
ItemDTO
item
:
changeSet
.
getUpdateItems
())
{
for
(
ItemDTO
item
:
changeSet
.
getUpdateItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
beforeUpdateItem
=
item
Repository
.
findOne
(
entity
.
getId
());
Item
beforeUpdateItem
=
item
Service
.
findOne
(
entity
.
getId
());
entity
.
setDataChangeLastModifiedBy
(
operator
);
entity
.
setDataChangeLastModifiedBy
(
operator
);
Item
updatedItem
=
itemService
.
update
(
entity
);
Item
updatedItem
=
itemService
.
update
(
entity
);
...
...
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