Package org.opencms.lock
Class CmsLockUtil.LockedFile
java.lang.Object
org.opencms.lock.CmsLockUtil.LockedFile
- All Implemented Interfaces:
AutoCloseable
- Enclosing class:
- CmsLockUtil
Helper to handle the lock reports together with the files.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Returns the encoding used for the file.getFile()
Returns the file, or null if reading fails.Returns the lock action record.boolean
Returns a flag, indicating if the file is newly created.static CmsLockUtil.LockedFile
lockResource
(CmsObject cms, CmsResource resource) Lock and read a file.void
setCreated
(boolean isNew) Set the flag, indicating if the file was newly created.boolean
Unlocks the resource if it was not formerly locked.
-
Method Details
-
lockResource
public static CmsLockUtil.LockedFile lockResource(CmsObject cms, CmsResource resource) throws CmsException Lock and read a file.- Parameters:
cms
- the cms user context.resource
- the resource to lock and read.- Returns:
- the read file with the lock action record.
- Throws:
CmsException
- thrown if locking fails
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
- See Also:
-
getEncoding
Returns the encoding used for the file.- Returns:
- the encoding used for the file.
- See Also:
-
getFile
Returns the file, or null if reading fails.- Returns:
- the file, or null if reading fails.
-
getLockActionRecord
Returns the lock action record.- Returns:
- the lock action record.
-
isCreated
Returns a flag, indicating if the file is newly created.- Returns:
- flag, indicating if the file is newly created.
-
setCreated
Set the flag, indicating if the file was newly created.- Parameters:
isNew
- flag, indicating if the file was newly created.
-
tryUnlock
Unlocks the resource if it was not formerly locked.- Returns:
true
in case the resource was unlocked
-