Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OLAT CI-CD Testing Project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lars Oliver Dam
OLAT CI-CD Testing Project
Commits
b0c42048
Commit
b0c42048
authored
13 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-70: double check the lock property in meta data, remove useless StringManager
parent
e2f927c5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/olat/core/util/servlets/VFSDirContext.java
+48
-43
48 additions, 43 deletions
src/main/java/org/olat/core/util/servlets/VFSDirContext.java
with
48 additions
and
43 deletions
src/main/java/org/olat/core/util/servlets/VFSDirContext.java
+
48
−
43
View file @
b0c42048
...
...
@@ -42,6 +42,7 @@ import javax.naming.NameClassPair;
import
javax.naming.NameNotFoundException
;
import
javax.naming.NamingEnumeration
;
import
javax.naming.NamingException
;
import
javax.naming.NoPermissionException
;
import
javax.naming.NotContextException
;
import
javax.naming.OperationNotSupportedException
;
import
javax.naming.directory.AttributeModificationException
;
...
...
@@ -89,11 +90,6 @@ public class VFSDirContext extends BaseDirContext {
// -------------------------------------------------------------- Constants
/**
* The string manager for this package.
*/
private
StringManager
smgr
=
new
StringManager
();
/**
* The descriptive information string for this implementation.
*/
...
...
@@ -248,7 +244,7 @@ public class VFSDirContext extends BaseDirContext {
public
Object
lookup
(
String
name
)
throws
NamingException
{
VFSItem
item
=
resolveFile
(
name
);
if
(
item
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
not
F
ound
"
,
name
)
)
;
if
(
item
==
null
)
throw
new
NamingException
(
"R
esources
not
f
ound
: "
+
name
);
if
(
item
instanceof
VFSContainer
)
{
VFSDirContext
tempContext
=
new
VFSDirContext
(
env
);
...
...
@@ -337,13 +333,21 @@ public class VFSDirContext extends BaseDirContext {
* @exception NamingException if a naming exception is encountered
*/
public
void
unbind
(
String
name
)
throws
NamingException
{
VFSItem
item
=
resolveFile
(
name
);
if
(
item
==
null
)
{
throw
new
NamingException
(
"Resources not found"
+
name
);
}
VFSItem
file
=
resolveFile
(
name
);
if
(
file
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"resources.notFound"
,
name
));
VFSStatus
status
=
file
.
delete
();
if
(
status
==
VFSConstants
.
NO
)
throw
new
NamingException
(
smgr
.
getString
(
"resources.unbindFailed"
,
name
));
if
(
item
!=
null
&&
VFSConstants
.
YES
.
equals
(
item
.
canDelete
()))
{
if
(
MetaInfoHelper
.
isLocked
(
item
,
userSession
))
{
throw
new
NamingException
(
"File locked: "
+
name
);
}
}
VFSStatus
status
=
item
.
delete
();
if
(
status
==
VFSConstants
.
NO
)
{
throw
new
NamingException
(
"resources unbind failed"
+
name
);
}
}
/**
...
...
@@ -360,15 +364,22 @@ public class VFSDirContext extends BaseDirContext {
public
void
rename
(
String
oldName
,
String
newName
)
throws
NamingException
{
VFSItem
oldFile
=
resolveFile
(
oldName
);
if
(
oldFile
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"resources.notFound"
,
oldName
));
if
(
oldFile
==
null
)
{
throw
new
NamingException
(
"Resources not found: "
+
oldName
);
}
if
(
MetaInfoHelper
.
isLocked
(
oldFile
,
userSession
))
{
throw
new
NoPermissionException
(
"Locked"
);
}
VFSItem
newFile
=
resolveFile
(
newName
);
if
(
newFile
!=
null
)
if
(
newFile
!=
null
)
{
throw
new
NameAlreadyBoundException
();
}
VFSStatus
status
=
oldFile
.
rename
(
newName
);
if
(
status
==
VFSConstants
.
NO
)
if
(
status
==
VFSConstants
.
NO
)
{
throw
new
NameAlreadyBoundException
();
}
}
/**
...
...
@@ -386,7 +397,7 @@ public class VFSDirContext extends BaseDirContext {
public
NamingEnumeration
<
NameClassPair
>
list
(
String
name
)
throws
NamingException
{
VFSItem
file
=
resolveFile
(
name
);
if
(
file
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
not
F
ound
"
,
name
)
)
;
if
(
file
==
null
)
throw
new
NamingException
(
"R
esources
not
f
ound
: "
+
name
);
return
new
NamingContextEnumeration
(
list
(
file
).
iterator
());
}
...
...
@@ -485,7 +496,7 @@ public class VFSDirContext extends BaseDirContext {
// Building attribute list
VFSItem
file
=
resolveFile
(
name
);
if
(
file
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
not
F
ound"
,
name
)
)
;
if
(
file
==
null
)
throw
new
NamingException
(
"R
esources
not
f
ound"
+
name
);
return
new
VFSResourceAttributes
(
file
);
}
...
...
@@ -552,7 +563,7 @@ public class VFSDirContext extends BaseDirContext {
// Note: No custom attributes allowed
VFSItem
file
=
resolveFile
(
name
);
if
(
file
!=
null
)
throw
new
NameAlreadyBoundException
(
smgr
.
getString
(
"r
esources
.
already
B
ound"
,
name
)
)
;
if
(
file
!=
null
)
throw
new
NameAlreadyBoundException
(
"R
esources
already
b
ound"
+
name
);
int
lastSlash
=
name
.
lastIndexOf
(
'/'
);
if
(
lastSlash
==
-
1
)
throw
new
NamingException
();
...
...
@@ -560,11 +571,11 @@ public class VFSDirContext extends BaseDirContext {
VFSItem
folder
=
resolveFile
(
parent
);
if
(
folder
==
null
||
(!(
folder
instanceof
VFSContainer
)))
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
bind
F
ailed
"
,
name
)
)
;
throw
new
NamingException
(
"R
esources
bind
f
ailed
: "
+
name
);
String
newName
=
name
.
substring
(
lastSlash
+
1
);
VFSLeaf
childLeaf
=
((
VFSContainer
)
folder
).
createChildLeaf
(
newName
);
if
(
childLeaf
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
bind
F
ailed
"
,
name
)
)
;
throw
new
NamingException
(
"R
esources
bind
f
ailed
: "
+
name
);
copyVFS
(
childLeaf
,
name
,
obj
,
attrs
);
VFSSecurityCallback
callback
=
folder
.
getLocalSecurityCallback
();
...
...
@@ -617,8 +628,12 @@ public class VFSDirContext extends BaseDirContext {
VFSItem
vfsItem
=
resolveFile
(
name
);
if
(
vfsItem
==
null
||
(!(
vfsItem
instanceof
VFSLeaf
)))
{
throw
new
NamingException
(
smgr
.
getString
(
"resources.bindFailed"
,
name
));
throw
new
NamingException
(
"Resources bind failed"
+
name
);
}
if
(
MetaInfoHelper
.
isLocked
(
vfsItem
,
userSession
))
{
throw
new
NoPermissionException
(
"Locked"
);
}
VFSLeaf
file
=
(
VFSLeaf
)
vfsItem
;
if
(
file
instanceof
Versionable
&&
((
Versionable
)
file
).
getVersions
().
isVersioned
())
{
if
(
file
.
getSize
()
==
0
)
{
...
...
@@ -663,7 +678,9 @@ public class VFSDirContext extends BaseDirContext {
createSubcontext
(
name
,
attrs
);
return
;
}
if
(
is
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"resources.bindFailed"
,
name
));
if
(
is
==
null
)
{
throw
new
NamingException
(
"Resources bind failed: "
+
name
);
}
// Try to get Quota
long
quotaLeft
=
-
1
;
...
...
@@ -697,8 +714,10 @@ public class VFSDirContext extends BaseDirContext {
}
catch
(
Exception
e
)
{
FileUtils
.
closeSafely
(
os
);
// close first, in order to be able to delete any reamins of the file
file
.
delete
();
if
(
e
instanceof
NamingException
)
throw
(
NamingException
)
e
;
throw
new
NamingException
(
smgr
.
getString
(
"resources.bindFailed"
));
if
(
e
instanceof
NamingException
)
{
throw
(
NamingException
)
e
;
}
throw
new
NamingException
(
"Resources bind failed"
);
}
finally
{
FileUtils
.
closeSafely
(
os
);
FileUtils
.
closeSafely
(
is
);
...
...
@@ -731,18 +750,18 @@ public class VFSDirContext extends BaseDirContext {
public
DirContext
createSubcontext
(
String
name
,
Attributes
attrs
)
throws
NamingException
{
VFSItem
file
=
resolveFile
(
name
);
if
(
file
!=
null
)
throw
new
NameAlreadyBoundException
(
smgr
.
getString
(
"r
esources
.
already
B
ound"
,
name
)
)
;
if
(
file
!=
null
)
throw
new
NameAlreadyBoundException
(
"R
esources
already
b
ound"
+
name
);
int
lastSlash
=
name
.
lastIndexOf
(
'/'
);
if
(
lastSlash
==
-
1
)
throw
new
NamingException
();
String
parent
=
name
.
substring
(
0
,
lastSlash
);
VFSItem
folder
=
resolveFile
(
parent
);
if
(
folder
==
null
||
(!(
folder
instanceof
VFSContainer
)))
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
bind
F
ailed"
,
name
)
)
;
throw
new
NamingException
(
"R
esources
bind
f
ailed"
+
name
);
String
newName
=
name
.
substring
(
lastSlash
+
1
);
VFSItem
childContainer
=
((
VFSContainer
)
folder
).
createChildContainer
(
newName
);
if
(
childContainer
==
null
)
throw
new
NamingException
(
smgr
.
getString
(
"r
esources
.
bind
F
ailed"
,
name
)
)
;
throw
new
NamingException
(
"R
esources
bind
f
ailed"
+
name
);
return
(
DirContext
)
lookup
(
name
);
}
...
...
@@ -957,6 +976,8 @@ public class VFSDirContext extends BaseDirContext {
* (to speed up simple checks, like checking the last modified date).
*/
protected
class
VFSResourceAttributes
extends
ResourceAttributes
{
private
static
final
long
serialVersionUID
=
4144775626100809634L
;
// -------------------------------------------------------- Constructor
...
...
@@ -1067,22 +1088,6 @@ public class VFSDirContext extends BaseDirContext {
}
protected
class
StringManager
{
public
StringManager
()
{
// dummy implementation
}
public
String
getString
(
String
in
)
{
return
in
;
}
public
String
getString
(
String
in
,
String
arg
)
{
return
in
;
}
}
/**
* Represents a binding in a NamingContext.
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment