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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
24 deletions
+25
-24
AppController.java
...amework/apollo/adminservice/controller/AppController.java
+10
-7
AppNamespaceController.java
...pollo/adminservice/controller/AppNamespaceController.java
+4
-4
ClusterController.java
...ork/apollo/adminservice/controller/ClusterController.java
+7
-5
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 {
private
AdminService
adminService
;
@RequestMapping
(
path
=
"/apps"
,
method
=
RequestMethod
.
POST
)
public
AppDTO
create
OrUpdate
(
@RequestBody
AppDTO
dto
)
{
public
AppDTO
create
(
@RequestBody
AppDTO
dto
)
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getAppId
()))
{
throw
new
BadRequestException
(
String
.
format
(
"AppId格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
}
App
entity
=
BeanUtils
.
transfrom
(
App
.
class
,
dto
);
App
managedEntity
=
appService
.
findOne
(
entity
.
getAppId
());
if
(
managedEntity
!=
null
)
{
BeanUtils
.
copyEntityProperties
(
entity
,
managedEntity
);
entity
=
appService
.
update
(
managedEntity
);
}
else
{
entity
=
adminService
.
createNewApp
(
entity
);
throw
new
BadRequestException
(
"app already exist."
);
}
entity
=
adminService
.
createNewApp
(
entity
);
dto
=
BeanUtils
.
transfrom
(
AppDTO
.
class
,
entity
);
return
dto
;
}
...
...
@@ -51,7 +50,9 @@ public class AppController {
@RequestMapping
(
path
=
"/apps/{appId}"
,
method
=
RequestMethod
.
DELETE
)
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@RequestParam
String
operator
)
{
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
);
}
...
...
@@ -70,7 +71,9 @@ public class AppController {
@RequestMapping
(
"/apps/{appId}"
)
public
AppDTO
get
(
@PathVariable
(
"appId"
)
String
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
);
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/AppNamespaceController.java
View file @
cd4e4759
...
...
@@ -22,17 +22,17 @@ public class AppNamespaceController {
private
AppNamespaceService
appNamespaceService
;
@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
managedEntity
=
appNamespaceService
.
findOne
(
entity
.
getAppId
(),
entity
.
getName
());
if
(
managedEntity
!=
null
){
if
(
managedEntity
!=
null
)
{
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
);
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/ClusterController.java
View file @
cd4e4759
...
...
@@ -25,7 +25,7 @@ public class ClusterController {
private
ClusterService
clusterService
;
@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
()))
{
throw
new
BadRequestException
(
String
.
format
(
"Cluster格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
}
...
...
@@ -33,9 +33,8 @@ public class ClusterController {
Cluster
managedEntity
=
clusterService
.
findOne
(
appId
,
entity
.
getName
());
if
(
managedEntity
!=
null
)
{
throw
new
BadRequestException
(
"cluster already exist."
);
}
else
{
entity
=
clusterService
.
save
(
entity
);
}
entity
=
clusterService
.
save
(
entity
);
dto
=
BeanUtils
.
transfrom
(
ClusterDTO
.
class
,
entity
);
return
dto
;
...
...
@@ -45,8 +44,9 @@ public class ClusterController {
public
void
delete
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
clusterName
,
@RequestParam
String
operator
)
{
Cluster
entity
=
clusterService
.
findOne
(
appId
,
clusterName
);
if
(
entity
==
null
)
if
(
entity
==
null
)
{
throw
new
NotFoundException
(
"cluster not found for clusterName "
+
clusterName
);
}
clusterService
.
delete
(
entity
.
getId
(),
operator
);
}
...
...
@@ -60,7 +60,9 @@ public class ClusterController {
public
ClusterDTO
get
(
@PathVariable
(
"appId"
)
String
appId
,
@PathVariable
(
"clusterName"
)
String
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
);
}
...
...
apollo-adminservice/src/main/java/com/ctrip/framework/apollo/adminservice/controller/NamespaceController.java
View file @
cd4e4759
...
...
@@ -25,7 +25,7 @@ public class NamespaceController {
private
NamespaceService
namespaceService
;
@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
)
{
if
(!
InputValidator
.
isValidClusterNamespace
(
dto
.
getNamespaceName
()))
{
throw
new
BadRequestException
(
String
.
format
(
"Namespace格式错误: %s"
,
InputValidator
.
INVALID_CLUSTER_NAMESPACE_MESSAGE
));
...
...
@@ -34,10 +34,10 @@ public class NamespaceController {
Namespace
managedEntity
=
namespaceService
.
findOne
(
appId
,
clusterName
,
entity
.
getNamespaceName
());
if
(
managedEntity
!=
null
)
{
throw
new
BadRequestException
(
"namespace already exist."
);
}
else
{
entity
=
namespaceService
.
save
(
entity
);
}
entity
=
namespaceService
.
save
(
entity
);
dto
=
BeanUtils
.
transfrom
(
NamespaceDTO
.
class
,
entity
);
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;
import
com.ctrip.framework.apollo.biz.entity.Audit
;
import
com.ctrip.framework.apollo.biz.entity.Commit
;
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.common.utils.BeanUtils
;
import
com.ctrip.framework.apollo.core.dto.ItemChangeSets
;
...
...
@@ -20,9 +19,6 @@ import com.ctrip.framework.apollo.core.utils.StringUtils;
public
class
ItemSetService
{
@Autowired
private
ItemRepository
itemRepository
;
@Autowired
private
AuditService
auditService
;
@Autowired
...
...
@@ -53,7 +49,7 @@ public class ItemSetService {
for
(
ItemDTO
item
:
changeSet
.
getUpdateItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
beforeUpdateItem
=
item
Repository
.
findOne
(
entity
.
getId
());
Item
beforeUpdateItem
=
item
Service
.
findOne
(
entity
.
getId
());
entity
.
setDataChangeLastModifiedBy
(
operator
);
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