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
fed39e80
Commit
fed39e80
authored
Apr 20, 2016
by
Yiming Liu
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #120 from lepdou/lepdou_master
commit log service & create app 表单优化
parents
90cb06f6
108034f4
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
186 additions
and
326 deletions
+186
-326
Commit.java
...biz/src/main/java/com/ctrip/apollo/biz/entity/Commit.java
+76
-0
CommitRepository.java
...ava/com/ctrip/apollo/biz/repository/CommitRepository.java
+14
-0
CommitService.java
...main/java/com/ctrip/apollo/biz/service/CommitService.java
+24
-0
ItemSetService.java
...ain/java/com/ctrip/apollo/biz/service/ItemSetService.java
+3
-0
AppConfigVO.java
.../src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
+0
-181
AppDTO.java
...-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
+6
-37
ItemChangeSets.java
...c/main/java/com/ctrip/apollo/core/dto/ItemChangeSets.java
+4
-0
ItemDTO.java
...core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
+9
-54
NamespaceDTO.java
...src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
+9
-10
ReleaseDTO.java
...e/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
+9
-10
AdminServiceAPI.java
...ain/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
+1
-1
NamespaceTextModel.java
...m/ctrip/apollo/portal/entity/form/NamespaceTextModel.java
+9
-0
ConfigService.java
...n/java/com/ctrip/apollo/portal/service/ConfigService.java
+4
-7
CreateAppController.js
...esources/static/scripts/controller/CreateAppController.js
+1
-5
AppConfigController.js
...rces/static/scripts/controller/app/AppConfigController.js
+7
-6
ConfigService.js
...c/main/resources/static/scripts/services/ConfigService.js
+2
-1
app.html
apollo-portal/src/main/resources/static/views/app.html
+1
-1
create-app.html
...lo-portal/src/main/resources/static/views/create-app.html
+4
-5
ConfigServiceTest.java
.../test/java/com/ctrip/apollo/portal/ConfigServiceTest.java
+3
-8
No files found.
apollo-biz/src/main/java/com/ctrip/apollo/biz/entity/Commit.java
0 → 100644
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
biz
.
entity
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
javax.persistence.Column
;
import
javax.persistence.Entity
;
import
javax.persistence.Table
;
@Entity
@Table
(
name
=
"commit"
)
@SQLDelete
(
sql
=
"Update commit set isDeleted = 1 where id = ?"
)
@Where
(
clause
=
"isDeleted = 0"
)
public
class
Commit
extends
BaseEntity
{
@Column
(
name
=
"ChangeSets"
,
nullable
=
false
)
private
String
changeSets
;
@Column
(
name
=
"AppId"
,
nullable
=
false
)
private
String
appId
;
@Column
(
name
=
"ClusterName"
,
nullable
=
false
)
private
String
clusterName
;
@Column
(
name
=
"NamespaceName"
,
nullable
=
false
)
private
String
namespaceName
;
@Column
(
name
=
"Comment"
)
private
String
comment
;
public
String
getChangeSets
()
{
return
changeSets
;
}
public
void
setChangeSets
(
String
changeSets
)
{
this
.
changeSets
=
changeSets
;
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
String
getClusterName
()
{
return
clusterName
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
}
public
String
getNamespaceName
()
{
return
namespaceName
;
}
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
@Override
public
String
toString
()
{
return
toStringHelper
().
add
(
"changeSets"
,
changeSets
).
add
(
"appId"
,
appId
).
add
(
"clusterName"
,
clusterName
)
.
add
(
"namespaceName"
,
namespaceName
).
add
(
"comment"
,
comment
).
toString
();
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/repository/CommitRepository.java
0 → 100644
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
biz
.
repository
;
import
com.ctrip.apollo.biz.entity.Commit
;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
java.util.List
;
public
interface
CommitRepository
extends
PagingAndSortingRepository
<
Commit
,
Long
>
{
List
<
Commit
>
findByAppIdAndClusterNameAndNamespaceName
(
String
appId
,
String
clusterName
,
String
namespaceName
);
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/CommitService.java
0 → 100644
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
biz
.
service
;
import
com.ctrip.apollo.biz.entity.Commit
;
import
com.ctrip.apollo.biz.repository.CommitRepository
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
@Service
public
class
CommitService
{
@Autowired
private
CommitRepository
commitRepository
;
public
void
save
(
Commit
commit
,
String
user
){
commit
.
setDataChangeCreatedBy
(
user
);
commit
.
setDataChangeCreatedTime
(
new
Date
());
commitRepository
.
save
(
commit
);
}
}
apollo-biz/src/main/java/com/ctrip/apollo/biz/service/ItemSetService.java
View file @
fed39e80
...
@@ -11,6 +11,8 @@ import com.ctrip.apollo.common.utils.BeanUtils;
...
@@ -11,6 +11,8 @@ import com.ctrip.apollo.common.utils.BeanUtils;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.apollo.core.dto.ItemChangeSets
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
com.ctrip.apollo.core.dto.ItemDTO
;
import
java.util.Date
;
@Service
@Service
public
class
ItemSetService
{
public
class
ItemSetService
{
...
@@ -25,6 +27,7 @@ public class ItemSetService {
...
@@ -25,6 +27,7 @@ public class ItemSetService {
if
(
changeSet
.
getCreateItems
()
!=
null
)
{
if
(
changeSet
.
getCreateItems
()
!=
null
)
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
for
(
ItemDTO
item
:
changeSet
.
getCreateItems
())
{
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
Item
entity
=
BeanUtils
.
transfrom
(
Item
.
class
,
item
);
entity
.
setDataChangeCreatedTime
(
new
Date
());
entity
.
setDataChangeCreatedBy
(
owner
);
entity
.
setDataChangeCreatedBy
(
owner
);
entity
.
setDataChangeLastModifiedBy
(
owner
);
entity
.
setDataChangeLastModifiedBy
(
owner
);
itemRepository
.
save
(
entity
);
itemRepository
.
save
(
entity
);
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppConfigVO.java
deleted
100644 → 0
View file @
90cb06f6
package
com
.
ctrip
.
apollo
.
core
.
dto
;
import
com.ctrip.apollo.core.enums.Env
;
import
java.util.LinkedList
;
import
java.util.List
;
public
class
AppConfigVO
{
private
String
appId
;
private
Env
env
;
/**
* latest version if version is zero, or is release version
*/
private
long
versionId
;
/**
* default cluster and app self’s configs
*/
private
List
<
ItemDTO
>
defaultClusterConfigs
;
/**
* default cluster and override other app configs
*/
private
List
<
OverrideAppConfig
>
overrideAppConfigs
;
/**
* configs in different cluster maybe different.
* overrideClusterConfigs only save diff configs from default cluster.
* For example:
* default cluster has 3 configs:
* {a -> A, b -> B, c -> C}
*
* cluster1 has 1 config
* {b -> D}
*
* if client read cluster1 configs will return {a -> A, b -> D, c -> C}
*/
private
List
<
OverrideClusterConfig
>
overrideClusterConfigs
;
public
AppConfigVO
()
{
}
public
static
AppConfigVO
newInstance
(
String
appId
,
long
versionId
)
{
AppConfigVO
instance
=
new
AppConfigVO
();
instance
.
setAppId
(
appId
);
instance
.
setVersionId
(
versionId
);
instance
.
setDefaultClusterConfigs
(
new
LinkedList
<>());
instance
.
setOverrideAppConfigs
(
new
LinkedList
<>());
instance
.
setOverrideClusterConfigs
(
new
LinkedList
<>());
return
instance
;
}
public
boolean
isLatestVersion
()
{
return
versionId
==
0
;
}
public
static
class
OverrideAppConfig
{
private
String
appId
;
private
List
<
ItemDTO
>
configs
;
public
OverrideAppConfig
()
{
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
List
<
ItemDTO
>
getConfigs
()
{
return
configs
;
}
public
void
setConfigs
(
List
<
ItemDTO
>
configs
)
{
this
.
configs
=
configs
;
}
public
void
addConfig
(
ItemDTO
config
)
{
if
(
configs
==
null
)
{
configs
=
new
LinkedList
<>();
}
configs
.
add
(
config
);
}
}
public
static
class
OverrideClusterConfig
{
private
String
clusterName
;
private
List
<
ItemDTO
>
configs
;
public
OverrideClusterConfig
()
{
}
public
String
getClusterName
()
{
return
clusterName
;
}
public
void
setClusterName
(
String
clusterName
)
{
this
.
clusterName
=
clusterName
;
}
public
List
<
ItemDTO
>
getConfigs
()
{
return
configs
;
}
public
void
setConfigs
(
List
<
ItemDTO
>
configs
)
{
this
.
configs
=
configs
;
}
}
public
String
getAppId
()
{
return
appId
;
}
public
void
setAppId
(
String
appId
)
{
this
.
appId
=
appId
;
}
public
Env
getEnv
()
{
return
env
;
}
public
void
setEnv
(
Env
env
)
{
this
.
env
=
env
;
}
public
long
getVersionId
()
{
return
versionId
;
}
public
void
setVersionId
(
long
versionId
)
{
this
.
versionId
=
versionId
;
}
public
List
<
ItemDTO
>
getDefaultClusterConfigs
()
{
return
defaultClusterConfigs
;
}
public
void
setDefaultClusterConfigs
(
List
<
ItemDTO
>
defaultClusterConfigs
)
{
this
.
defaultClusterConfigs
=
defaultClusterConfigs
;
}
public
List
<
OverrideAppConfig
>
getOverrideAppConfigs
()
{
return
overrideAppConfigs
;
}
public
void
setOverrideAppConfigs
(
List
<
OverrideAppConfig
>
overrideAppConfigs
)
{
this
.
overrideAppConfigs
=
overrideAppConfigs
;
}
public
List
<
OverrideClusterConfig
>
getOverrideClusterConfigs
()
{
return
overrideClusterConfigs
;
}
public
void
setOverrideClusterConfigs
(
List
<
OverrideClusterConfig
>
overrideClusterConfigs
)
{
this
.
overrideClusterConfigs
=
overrideClusterConfigs
;
}
@Override
public
String
toString
()
{
return
"Config4PortalDTO{"
+
"appId="
+
appId
+
", env="
+
env
+
", versionId="
+
versionId
+
", defaultClusterConfigs="
+
defaultClusterConfigs
+
", overrideAppConfigs="
+
overrideAppConfigs
+
", overrideClusterConfigs="
+
overrideClusterConfigs
+
'}'
;
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/AppDTO.java
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
core
.
dto
;
package
com
.
ctrip
.
apollo
.
core
.
dto
;
import
java.util.Date
;
public
class
AppDTO
{
public
class
AppDTO
{
private
long
id
;
private
long
id
;
...
@@ -14,20 +12,18 @@ public class AppDTO {
...
@@ -14,20 +12,18 @@ public class AppDTO {
private
String
ownerEmail
;
private
String
ownerEmail
;
p
rivate
String
dataChangeCreatedBy
;
p
ublic
long
getId
()
{
return
id
;
private
Date
dataChangeCreatedTime
;
}
private
String
dataChangeLastModifiedBy
;
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
public
String
getAppId
()
{
return
appId
;
return
appId
;
}
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
@@ -44,10 +40,6 @@ public class AppDTO {
...
@@ -44,10 +40,6 @@ public class AppDTO {
this
.
appId
=
appId
;
this
.
appId
=
appId
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
...
@@ -60,27 +52,4 @@ public class AppDTO {
...
@@ -60,27 +52,4 @@ public class AppDTO {
this
.
ownerName
=
ownerName
;
this
.
ownerName
=
ownerName
;
}
}
public
String
getDataChangeCreatedBy
()
{
return
dataChangeCreatedBy
;
}
public
void
setDataChangeCreatedBy
(
String
dataChangeCreatedBy
)
{
this
.
dataChangeCreatedBy
=
dataChangeCreatedBy
;
}
public
Date
getDataChangeCreatedTime
()
{
return
dataChangeCreatedTime
;
}
public
void
setDataChangeCreatedTime
(
Date
dataChangeCreatedTime
)
{
this
.
dataChangeCreatedTime
=
dataChangeCreatedTime
;
}
public
String
getDataChangeLastModifiedBy
()
{
return
dataChangeLastModifiedBy
;
}
public
void
setDataChangeLastModifiedBy
(
String
dataChangeLastModifiedBy
)
{
this
.
dataChangeLastModifiedBy
=
dataChangeLastModifiedBy
;
}
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemChangeSets.java
View file @
fed39e80
...
@@ -24,6 +24,10 @@ public class ItemChangeSets {
...
@@ -24,6 +24,10 @@ public class ItemChangeSets {
deleteItems
.
add
(
item
);
deleteItems
.
add
(
item
);
}
}
public
boolean
isEmpty
(){
return
createItems
.
isEmpty
()
&&
updateItems
.
isEmpty
()
&&
deleteItems
.
isEmpty
();
}
public
List
<
ItemDTO
>
getCreateItems
()
{
public
List
<
ItemDTO
>
getCreateItems
()
{
return
createItems
;
return
createItems
;
}
}
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ItemDTO.java
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
core
.
dto
;
package
com
.
ctrip
.
apollo
.
core
.
dto
;
import
java.util.Date
;
public
class
ItemDTO
{
public
class
ItemDTO
{
private
long
id
;
private
long
id
;
...
@@ -16,14 +14,6 @@ public class ItemDTO{
...
@@ -16,14 +14,6 @@ public class ItemDTO{
private
int
lineNum
;
private
int
lineNum
;
private
String
dataChangeCreatedBy
;
private
Date
dataChangeCreatedTime
;
private
String
dataChangeLastModifiedBy
;
private
Date
dataChangeLastModifiedTime
;
public
ItemDTO
()
{
public
ItemDTO
()
{
}
}
...
@@ -35,14 +25,18 @@ public class ItemDTO{
...
@@ -35,14 +25,18 @@ public class ItemDTO{
this
.
lineNum
=
lineNum
;
this
.
lineNum
=
lineNum
;
}
}
public
String
getComment
()
{
return
comment
;
}
public
long
getId
()
{
public
long
getId
()
{
return
id
;
return
id
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getComment
()
{
return
comment
;
}
public
String
getKey
()
{
public
String
getKey
()
{
return
key
;
return
key
;
}
}
...
@@ -59,10 +53,6 @@ public class ItemDTO{
...
@@ -59,10 +53,6 @@ public class ItemDTO{
this
.
comment
=
comment
;
this
.
comment
=
comment
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setKey
(
String
key
)
{
public
void
setKey
(
String
key
)
{
this
.
key
=
key
;
this
.
key
=
key
;
}
}
...
@@ -83,37 +73,6 @@ public class ItemDTO{
...
@@ -83,37 +73,6 @@ public class ItemDTO{
this
.
lineNum
=
lineNum
;
this
.
lineNum
=
lineNum
;
}
}
public
String
getDataChangeLastModifiedBy
()
{
return
dataChangeLastModifiedBy
;
}
public
void
setDataChangeLastModifiedBy
(
String
dataChangeLastModifiedBy
)
{
this
.
dataChangeLastModifiedBy
=
dataChangeLastModifiedBy
;
}
public
Date
getDataChangeLastModifiedTime
()
{
return
dataChangeLastModifiedTime
;
}
public
void
setDataChangeLastModifiedTime
(
Date
dataChangeLastModifiedTime
)
{
this
.
dataChangeLastModifiedTime
=
dataChangeLastModifiedTime
;
}
public
String
getDataChangeCreatedBy
()
{
return
dataChangeCreatedBy
;
}
public
void
setDataChangeCreatedBy
(
String
dataChangeCreatedBy
)
{
this
.
dataChangeCreatedBy
=
dataChangeCreatedBy
;
}
public
Date
getDataChangeCreatedTime
()
{
return
dataChangeCreatedTime
;
}
public
void
setDataChangeCreatedTime
(
Date
dataChangeCreatedTime
)
{
this
.
dataChangeCreatedTime
=
dataChangeCreatedTime
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
...
@@ -124,10 +83,6 @@ public class ItemDTO{
...
@@ -124,10 +83,6 @@ public class ItemDTO{
", value='"
+
value
+
'\''
+
", value='"
+
value
+
'\''
+
", comment='"
+
comment
+
'\''
+
", comment='"
+
comment
+
'\''
+
", lineNum="
+
lineNum
+
", lineNum="
+
lineNum
+
", dataChangeCreatedBy='"
+
dataChangeCreatedBy
+
'\''
+
", dataChangeCreatedTime="
+
dataChangeCreatedTime
+
", dataChangeLastModifiedBy='"
+
dataChangeLastModifiedBy
+
'\''
+
", dataChangeLastModifiedTime="
+
dataChangeLastModifiedTime
+
'}'
;
'}'
;
}
}
}
}
apollo-core/src/main/java/com/ctrip/apollo/core/dto/NamespaceDTO.java
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
core
.
dto
;
package
com
.
ctrip
.
apollo
.
core
.
dto
;
public
class
NamespaceDTO
{
public
class
NamespaceDTO
{
private
long
id
;
private
long
id
;
private
String
appId
;
private
String
appId
;
...
@@ -10,6 +9,14 @@ public class NamespaceDTO {
...
@@ -10,6 +9,14 @@ public class NamespaceDTO {
private
String
namespaceName
;
private
String
namespaceName
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
public
String
getAppId
()
{
return
appId
;
return
appId
;
}
}
...
@@ -18,10 +25,6 @@ public class NamespaceDTO {
...
@@ -18,10 +25,6 @@ public class NamespaceDTO {
return
clusterName
;
return
clusterName
;
}
}
public
long
getId
()
{
return
id
;
}
public
String
getNamespaceName
()
{
public
String
getNamespaceName
()
{
return
namespaceName
;
return
namespaceName
;
}
}
...
@@ -34,10 +37,6 @@ public class NamespaceDTO {
...
@@ -34,10 +37,6 @@ public class NamespaceDTO {
this
.
clusterName
=
clusterName
;
this
.
clusterName
=
clusterName
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setNamespaceName
(
String
namespaceName
)
{
public
void
setNamespaceName
(
String
namespaceName
)
{
this
.
namespaceName
=
namespaceName
;
this
.
namespaceName
=
namespaceName
;
}
}
...
...
apollo-core/src/main/java/com/ctrip/apollo/core/dto/ReleaseDTO.java
View file @
fed39e80
package
com
.
ctrip
.
apollo
.
core
.
dto
;
package
com
.
ctrip
.
apollo
.
core
.
dto
;
public
class
ReleaseDTO
{
public
class
ReleaseDTO
{
private
long
id
;
private
long
id
;
private
String
name
;
private
String
name
;
...
@@ -16,6 +15,14 @@ public class ReleaseDTO {
...
@@ -16,6 +15,14 @@ public class ReleaseDTO {
private
String
comment
;
private
String
comment
;
public
long
getId
()
{
return
id
;
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
String
getAppId
()
{
public
String
getAppId
()
{
return
appId
;
return
appId
;
}
}
...
@@ -32,10 +39,6 @@ public class ReleaseDTO {
...
@@ -32,10 +39,6 @@ public class ReleaseDTO {
return
configurations
;
return
configurations
;
}
}
public
long
getId
()
{
return
id
;
}
public
String
getName
()
{
public
String
getName
()
{
return
name
;
return
name
;
}
}
...
@@ -60,10 +63,6 @@ public class ReleaseDTO {
...
@@ -60,10 +63,6 @@ public class ReleaseDTO {
this
.
configurations
=
configurations
;
this
.
configurations
=
configurations
;
}
}
public
void
setId
(
long
id
)
{
this
.
id
=
id
;
}
public
void
setName
(
String
name
)
{
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
this
.
name
=
name
;
}
}
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/api/AdminServiceAPI.java
View file @
fed39e80
...
@@ -165,7 +165,7 @@ public class AdminServiceAPI {
...
@@ -165,7 +165,7 @@ public class AdminServiceAPI {
}
else
{
}
else
{
logger
.
error
(
"createRelease fail.id:{}, env:{}, clusterName:{}, namespace:{},releaseBy{}"
,
logger
.
error
(
"createRelease fail.id:{}, env:{}, clusterName:{}, namespace:{},releaseBy{}"
,
appId
,
env
,
clusterName
,
namespace
,
releaseBy
);
appId
,
env
,
clusterName
,
namespace
,
releaseBy
);
throw
new
ServiceException
(
"call create createRelease api error."
);
throw
new
ServiceException
(
"
call create createRelease api error."
);
}
}
}
}
}
}
...
...
apollo-portal/src/main/java/com/ctrip/apollo/portal/entity/form/NamespaceTextModel.java
View file @
fed39e80
...
@@ -13,6 +13,7 @@ public class NamespaceTextModel implements FormModel{
...
@@ -13,6 +13,7 @@ public class NamespaceTextModel implements FormModel{
private
int
namespaceId
;
private
int
namespaceId
;
private
String
configText
;
private
String
configText
;
private
String
modifyBy
;
private
String
modifyBy
;
private
String
comment
;
@Override
@Override
public
boolean
isInvalid
(){
public
boolean
isInvalid
(){
...
@@ -73,4 +74,12 @@ public class NamespaceTextModel implements FormModel{
...
@@ -73,4 +74,12 @@ public class NamespaceTextModel implements FormModel{
public
void
setModifyBy
(
String
modifyBy
)
{
public
void
setModifyBy
(
String
modifyBy
)
{
this
.
modifyBy
=
modifyBy
;
this
.
modifyBy
=
modifyBy
;
}
}
public
String
getComment
()
{
return
comment
;
}
public
void
setComment
(
String
comment
)
{
this
.
comment
=
comment
;
}
}
}
apollo-portal/src/main/java/com/ctrip/apollo/portal/service/ConfigService.java
View file @
fed39e80
...
@@ -146,22 +146,19 @@ public class ConfigService {
...
@@ -146,22 +146,19 @@ public class ConfigService {
ItemChangeSets
changeSets
=
resolver
.
resolve
(
namespaceId
,
configText
,
ItemChangeSets
changeSets
=
resolver
.
resolve
(
namespaceId
,
configText
,
itemAPI
.
findItems
(
appId
,
env
,
clusterName
,
namespaceName
));
itemAPI
.
findItems
(
appId
,
env
,
clusterName
,
namespaceName
));
if
(
changeSets
.
isEmpty
()){
return
;
}
try
{
try
{
enrichChangeSetBaseInfo
(
changeSets
);
itemAPI
.
updateItems
(
appId
,
env
,
clusterName
,
namespaceName
,
changeSets
);
itemAPI
.
updateItems
(
appId
,
env
,
clusterName
,
namespaceName
,
changeSets
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"itemAPI.updateItems error. appId{},env:{},clusterName:{},namespaceName:{}"
,
appId
,
env
,
clusterName
,
logger
.
error
(
"itemAPI.updateItems error. appId{},env:{},clusterName:{},namespaceName:{}"
,
appId
,
env
,
clusterName
,
namespaceName
);
namespaceName
);
throw
new
ServiceException
(
"oops! call admin service config error. "
);
throw
new
ServiceException
(
e
.
getMessage
()
);
}
}
}
}
private
void
enrichChangeSetBaseInfo
(
ItemChangeSets
changeSets
)
{
for
(
ItemDTO
item
:
changeSets
.
getCreateItems
())
{
item
.
setDataChangeCreatedTime
(
new
Date
());
}
}
/**
/**
* createRelease config items
* createRelease config items
...
...
apollo-portal/src/main/resources/static/scripts/controller/CreateAppController.js
View file @
fed39e80
...
@@ -8,11 +8,7 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast
...
@@ -8,11 +8,7 @@ create_app_module.controller('CreateAppController', ['$scope', '$window', 'toast
$window
.
location
.
href
=
'/views/app.html?#appid='
+
result
.
appId
;
$window
.
location
.
href
=
'/views/app.html?#appid='
+
result
.
appId
;
},
1000
);
},
1000
);
},
function
(
result
)
{
},
function
(
result
)
{
if
(
result
.
status
==
400
){
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
'添加失败!'
);
toastr
.
error
(
'params error'
,
'添加失败!'
);
}
else
{
toastr
.
error
(
'server error'
,
'添加失败!'
);
}
});
});
};
};
...
...
apollo-portal/src/main/resources/static/scripts/controller/app/AppConfigController.js
View file @
fed39e80
...
@@ -3,7 +3,7 @@ application_module.controller("AppConfigController",
...
@@ -3,7 +3,7 @@ application_module.controller("AppConfigController",
function
(
$scope
,
$location
,
toastr
,
AppService
,
ConfigService
)
{
function
(
$scope
,
$location
,
toastr
,
AppService
,
ConfigService
)
{
var
appId
=
$location
.
$$url
.
split
(
"="
)[
1
];
var
appId
=
$location
.
$$url
.
split
(
"="
)[
1
];
var
currentUser
=
'
lepdou
'
;
var
currentUser
=
'
test_user
'
;
var
pageContext
=
{
var
pageContext
=
{
appId
:
appId
,
appId
:
appId
,
env
:
'LOCAL'
,
env
:
'LOCAL'
,
...
@@ -49,7 +49,7 @@ application_module.controller("AppConfigController",
...
@@ -49,7 +49,7 @@ application_module.controller("AppConfigController",
}
}
});
});
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
"加载导航出错:"
+
result
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"加载导航出错"
);
});
});
/////////// namespace ////////////
/////////// namespace ////////////
...
@@ -84,7 +84,7 @@ application_module.controller("AppConfigController",
...
@@ -84,7 +84,7 @@ application_module.controller("AppConfigController",
}
}
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
"加载配置信息出错"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"加载配置信息出错"
);
});
});
}
}
...
@@ -127,11 +127,12 @@ application_module.controller("AppConfigController",
...
@@ -127,11 +127,12 @@ application_module.controller("AppConfigController",
$scope
.
draft
=
namespace
;
$scope
.
draft
=
namespace
;
};
};
$scope
.
commitComment
=
''
;
//更新配置
//更新配置
$scope
.
commitChange
=
function
()
{
$scope
.
commitChange
=
function
()
{
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
ConfigService
.
modify_items
(
$scope
.
pageContext
.
appId
,
$scope
.
pageContext
.
env
,
$scope
.
pageContext
.
clusterName
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
$scope
.
draft
.
namespace
.
namespaceName
,
$scope
.
draft
.
text
,
$scope
.
draft
.
namespace
.
id
,
'lepdou'
).
then
(
$scope
.
draft
.
namespace
.
id
,
$scope
.
commitComment
,
currentUser
).
then
(
function
(
result
)
{
function
(
result
)
{
toastr
.
success
(
"更新成功"
);
toastr
.
success
(
"更新成功"
);
//refresh all namespace items
//refresh all namespace items
...
@@ -141,7 +142,7 @@ application_module.controller("AppConfigController",
...
@@ -141,7 +142,7 @@ application_module.controller("AppConfigController",
$scope
.
toggleTextEditStatus
(
$scope
.
draft
);
$scope
.
toggleTextEditStatus
(
$scope
.
draft
);
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
result
.
data
.
message
,
"更新失败"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"更新失败"
);
}
}
);
);
...
@@ -189,7 +190,7 @@ application_module.controller("AppConfigController",
...
@@ -189,7 +190,7 @@ application_module.controller("AppConfigController",
refreshNamespaces
();
refreshNamespaces
();
},
function
(
result
)
{
},
function
(
result
)
{
toastr
.
error
(
result
.
data
.
message
,
"发布失败"
);
toastr
.
error
(
result
.
status
+
result
.
data
.
message
,
"发布失败"
);
}
}
);
);
...
...
apollo-portal/src/main/resources/static/scripts/services/ConfigService.js
View file @
fed39e80
...
@@ -30,7 +30,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
...
@@ -30,7 +30,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
return
d
.
promise
;
return
d
.
promise
;
},
},
modify_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
configText
,
namespaceId
,
modifyBy
)
{
modify_items
:
function
(
appId
,
env
,
clusterName
,
namespaceName
,
configText
,
namespaceId
,
comment
,
modifyBy
)
{
var
d
=
$q
.
defer
();
var
d
=
$q
.
defer
();
config_source
.
modify_items
({
config_source
.
modify_items
({
appId
:
appId
,
appId
:
appId
,
...
@@ -41,6 +41,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
...
@@ -41,6 +41,7 @@ appService.service("ConfigService", ['$resource', '$q', function ($resource, $q)
{
{
configText
:
configText
,
configText
:
configText
,
namespaceId
:
namespaceId
,
namespaceId
:
namespaceId
,
comment
:
comment
,
modifyBy
:
modifyBy
modifyBy
:
modifyBy
},
function
(
result
)
{
},
function
(
result
)
{
d
.
resolve
(
result
);
d
.
resolve
(
result
);
...
...
apollo-portal/src/main/resources/static/views/app.html
View file @
fed39e80
...
@@ -241,7 +241,7 @@
...
@@ -241,7 +241,7 @@
<h4
class=
"modal-title"
id=
"myModalLabel2"
>
Commit changes
</h4>
<h4
class=
"modal-title"
id=
"myModalLabel2"
>
Commit changes
</h4>
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"input change log...."
></textarea>
<textarea
rows=
"4"
class=
"form-control"
style=
"width:570px;"
placeholder=
"input change log...."
ng-model=
"commitComment"
></textarea>
</div>
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"commitChange()"
>
提交
</button>
<button
type=
"button"
class=
"btn btn-primary"
data-dismiss=
"modal"
ng-click=
"commitChange()"
>
提交
</button>
...
...
apollo-portal/src/main/resources/static/views/create-app.html
View file @
fed39e80
...
@@ -38,17 +38,16 @@
...
@@ -38,17 +38,16 @@
<input
type=
"text"
class=
"form-control"
name=
"appName"
ng-model=
"app.name"
required
>
<input
type=
"text"
class=
"form-control"
name=
"appName"
ng-model=
"app.name"
required
>
</div>
</div>
</div>
</div>
<!--接入sso之后将会去除-->
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
Owner
</label>
<label
class=
"col-sm-2 control-label"
>
<font
style=
"color: red"
>
*
</font>
应用
Owner
</label>
<div
class=
"col-sm-3"
>
<div
class=
"col-sm-3"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
>
<input
type=
"text"
class=
"form-control"
name=
"appOwner"
ng-model=
"app.ownerName"
required
>
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
邮箱地址
</label>
<label
class=
"col-sm-2 control-label"
>
<font
style=
"color: red"
>
*
</font>
邮箱地址
</label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
>
<input
type=
"email"
class=
"form-control"
ng-model=
"app.ownerEmail"
required
>
</div>
</div>
</div>
</div>
...
...
apollo-portal/src/test/java/com/ctrip/apollo/portal/ConfigServiceTest.java
View file @
fed39e80
...
@@ -5,7 +5,6 @@ import com.ctrip.apollo.core.dto.ItemDTO;
...
@@ -5,7 +5,6 @@ import com.ctrip.apollo.core.dto.ItemDTO;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
import
com.ctrip.apollo.core.dto.NamespaceDTO
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.ctrip.apollo.core.dto.ReleaseDTO
;
import
com.ctrip.apollo.core.enums.Env
;
import
com.ctrip.apollo.core.enums.Env
;
import
com.ctrip.apollo.core.exception.ServiceException
;
import
com.ctrip.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.apollo.portal.api.AdminServiceAPI
;
import
com.ctrip.apollo.portal.entity.NamespaceVO
;
import
com.ctrip.apollo.portal.entity.NamespaceVO
;
import
com.ctrip.apollo.portal.entity.form.NamespaceTextModel
;
import
com.ctrip.apollo.portal.entity.form.NamespaceTextModel
;
...
@@ -101,22 +100,18 @@ public class ConfigServiceTest extends AbstractPortalTest{
...
@@ -101,22 +100,18 @@ public class ConfigServiceTest extends AbstractPortalTest{
model
.
setNamespaceName
(
namespaceName
);
model
.
setNamespaceName
(
namespaceName
);
model
.
setClusterName
(
clusterName
);
model
.
setClusterName
(
clusterName
);
model
.
setAppId
(
appId
);
model
.
setAppId
(
appId
);
model
.
setConfigText
(
"a=b\nb=c\nc=d"
);
model
.
setConfigText
(
"a=b\nb=c\nc=d\nd=e"
);
List
<
ItemDTO
>
itemDTOs
=
mockBaseItemHas3Key
();
List
<
ItemDTO
>
itemDTOs
=
mockBaseItemHas3Key
();
ItemChangeSets
changeSets
=
new
ItemChangeSets
();
ItemChangeSets
changeSets
=
new
ItemChangeSets
();
changeSets
.
addCreateItem
(
new
ItemDTO
(
"d"
,
"c"
,
""
,
4
));
changeSets
.
addCreateItem
(
new
ItemDTO
(
"d"
,
"c"
,
""
,
4
));
when
(
itemAPI
.
findItems
(
appId
,
Env
.
DEV
,
clusterName
,
namespaceName
)).
thenReturn
(
itemDTOs
);
when
(
itemAPI
.
findItems
(
appId
,
Env
.
DEV
,
clusterName
,
namespaceName
)).
thenReturn
(
itemDTOs
);
when
(
resolver
.
resolve
(
0
,
model
.
getConfigText
(),
itemDTOs
)).
thenReturn
(
changeSets
);
try
{
try
{
// 调用itemAPI.updateConfig 会抛出ServiceException.
// itemAPI.updateConfig ut 放在admin service.
// 所以只要在调用itemAPI.updateConfig前全部通过,此ut应该通过.
configService
.
updateConfigItemByText
(
model
);
configService
.
updateConfigItemByText
(
model
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
Assert
.
assertTrue
(
e
instanceof
ServiceException
);
Assert
.
fail
(
);
}
}
}
}
...
...
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