Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
jenkins
提交
fa4fc30c
J
jenkins
项目概览
xxadev
/
jenkins
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jenkins
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fa4fc30c
编写于
9月 16, 2014
作者:
S
Stephen Connolly
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tidy up other code paths
上级
e919acb5
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
35 addition
and
7 deletion
+35
-7
core/src/main/java/hudson/model/ItemGroupMixIn.java
core/src/main/java/hudson/model/ItemGroupMixIn.java
+19
-7
core/src/main/java/hudson/model/TopLevelItemDescriptor.java
core/src/main/java/hudson/model/TopLevelItemDescriptor.java
+14
-0
core/src/main/resources/hudson/model/Messages.properties
core/src/main/resources/hudson/model/Messages.properties
+2
-0
未找到文件。
core/src/main/java/hudson/model/ItemGroupMixIn.java
浏览文件 @
fa4fc30c
...
...
@@ -191,6 +191,8 @@ public abstract class ItemGroupMixIn {
if
(
descriptor
==
null
)
{
throw
new
Failure
(
"No item type ‘"
+
mode
+
"’ is known"
);
}
descriptor
.
checkApplicableIn
(
parent
);
acl
.
getACL
().
checkCreatePermission
(
parent
,
descriptor
);
// create empty job and redirect to the project config screen
result
=
createProject
(
descriptor
,
name
,
true
);
...
...
@@ -215,6 +217,8 @@ public abstract class ItemGroupMixIn {
public
synchronized
<
T
extends
TopLevelItem
>
T
copy
(
T
src
,
String
name
)
throws
IOException
{
acl
.
checkPermission
(
Item
.
CREATE
);
src
.
checkPermission
(
Item
.
EXTENDED_READ
);
src
.
getDescriptor
().
checkApplicableIn
(
parent
);
acl
.
getACL
().
checkCreatePermission
(
parent
,
src
.
getDescriptor
());
T
result
=
(
T
)
createProject
(
src
.
getDescriptor
(),
name
,
false
);
...
...
@@ -250,6 +254,7 @@ public abstract class ItemGroupMixIn {
File
configXml
=
Items
.
getConfigFile
(
getRootDirFor
(
name
)).
getFile
();
final
File
dir
=
configXml
.
getParentFile
();
dir
.
mkdirs
();
boolean
success
=
false
;
try
{
IOUtils
.
copy
(
xml
,
configXml
);
...
...
@@ -259,27 +264,34 @@ public abstract class ItemGroupMixIn {
return
(
TopLevelItem
)
Items
.
load
(
parent
,
dir
);
}
});
acl
.
getACL
().
checkCreatePermission
(
parent
,
result
.
getDescriptor
());
success
=
acl
.
getACL
().
hasCreatePermission
(
Jenkins
.
getAuthentication
(),
parent
,
result
.
getDescriptor
())
&&
result
.
getDescriptor
().
isApplicableIn
(
parent
);
add
(
result
);
ItemListener
.
fireOnCreated
(
result
);
Jenkins
.
getInstance
().
rebuildDependencyGraphAsync
();
return
result
;
}
catch
(
AccessDeniedException
e
)
{
// if anything fails, delete the config file to avoid further confusion
Util
.
deleteRecursive
(
dir
);
throw
e
;
}
catch
(
IOException
e
)
{
success
=
false
;
throw
e
;
}
catch
(
RuntimeException
e
)
{
success
=
false
;
throw
e
;
}
finally
{
if
(!
success
)
{
// if anything fails, delete the config file to avoid further confusion
Util
.
deleteRecursive
(
dir
);
throw
e
;
}
}
}
public
synchronized
TopLevelItem
createProject
(
TopLevelItemDescriptor
type
,
String
name
,
boolean
notify
)
throws
IOException
{
acl
.
checkPermission
(
Item
.
CREATE
);
type
.
checkApplicableIn
(
parent
);
acl
.
getACL
().
checkCreatePermission
(
parent
,
type
);
Jenkins
.
getInstance
().
getProjectNamingStrategy
().
checkName
(
name
);
...
...
core/src/main/java/hudson/model/TopLevelItemDescriptor.java
浏览文件 @
fa4fc30c
...
...
@@ -25,6 +25,7 @@ package hudson.model;
import
hudson.ExtensionList
;
import
jenkins.model.Jenkins
;
import
org.acegisecurity.AccessDeniedException
;
import
org.kohsuke.stapler.StaplerRequest
;
/**
...
...
@@ -71,6 +72,19 @@ public abstract class TopLevelItemDescriptor extends Descriptor<TopLevelItem> {
return
true
;
}
/**
* Checks if this top level item is applicable within the specified item group.
* <p>
* This is just a convenience function.
* @since 1.582
*/
public
final
void
checkApplicableIn
(
ItemGroup
parent
)
{
if
(!
isApplicableIn
(
parent
))
{
throw
new
AccessDeniedException
(
Messages
.
TopLevelItemDescriptor_NotApplicableIn
(
getDisplayName
(),
parent
.
getFullDisplayName
()));
}
}
/**
* Tests if the given instance belongs to this descriptor, in the sense
* that this descriptor can produce items like the given one.
...
...
core/src/main/resources/hudson/model/Messages.properties
浏览文件 @
fa4fc30c
...
...
@@ -251,6 +251,8 @@ Slave.UnableToLaunch=Unable to launch the slave agent for {0}{1}
Slave.UnixSlave
=
This is a Unix slave
Slave.WindowsSlave
=
This is a Windows slave
TopLevelItemDescriptor.NotApplicableIn
=
{0} items are not applicable within {1}
UpdateCenter.DownloadButNotActivated
=
Downloaded Successfully. Will be activated during the next boot
UpdateCenter.n_a
=
N/A
View.Permissions.Title
=
View
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录