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
35984989
Commit
35984989
authored
12 years ago
by
srosse
Browse files
Options
Downloads
Patches
Plain Diff
OO-420: modernize CatalogManager
parent
af2691bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/org/olat/catalog/CatalogEntryImpl.java
+2
-0
2 additions, 0 deletions
src/main/java/org/olat/catalog/CatalogEntryImpl.java
src/main/java/org/olat/catalog/CatalogManager.java
+89
-145
89 additions, 145 deletions
src/main/java/org/olat/catalog/CatalogManager.java
with
91 additions
and
145 deletions
src/main/java/org/olat/catalog/CatalogEntryImpl.java
+
2
−
0
View file @
35984989
...
...
@@ -38,6 +38,8 @@ import org.olat.repository.RepositoryEntry;
* @author Felix Jost
*/
public
class
CatalogEntryImpl
extends
PersistentObject
implements
CatalogEntry
{
private
static
final
long
serialVersionUID
=
2834235462805397562L
;
private
String
name
;
private
String
description
;
private
String
externalURL
;
...
...
This diff is collapsed.
Click to expand it.
src/main/java/org/olat/catalog/CatalogManager.java
+
89
−
145
View file @
35984989
...
...
@@ -33,20 +33,17 @@ import javax.persistence.TypedQuery;
import
org.olat.admin.user.delete.service.UserDeletionManager
;
import
org.olat.basesecurity.BaseSecurity
;
import
org.olat.basesecurity.BaseSecurityManager
;
import
org.olat.basesecurity.Constants
;
import
org.olat.basesecurity.SecurityGroup
;
import
org.olat.core.commons.persistence.DB
;
import
org.olat.core.commons.persistence.DBFactory
;
import
org.olat.core.commons.persistence.DBQuery
;
import
org.olat.core.commons.persistence.PersistenceHelper
;
import
org.olat.core.configuration.Initializable
;
import
org.olat.core.id.Identity
;
import
org.olat.core.id.OLATResourceable
;
import
org.olat.core.logging.Tracing
;
import
org.olat.core.manager.BasicManager
;
import
org.olat.core.util.coordinate.CoordinatorManager
;
import
org.olat.core.util.event.MultiUserEvent
;
import
org.olat.core.util.resource.Resourceable
;
import
org.olat.repository.RepositoryEntry
;
import
org.olat.repository.RepositoryManager
;
import
org.olat.repository.controllers.EntryChangedEvent
;
...
...
@@ -86,6 +83,8 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
private
DB
dbInstance
;
@Autowired
private
BaseSecurity
securityManager
;
@Autowired
private
RepositoryManager
repositoryManager
;
/**
* [spring]
...
...
@@ -133,7 +132,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
sb
.
append
(
" order by cei."
).
append
(
orderBy
.
name
()).
append
(
asc
?
" ASC"
:
" DESC"
);
}
TypedQuery
<
CatalogEntry
>
dbQuery
=
DBFactory
.
get
Instance
()
.
getCurrentEntityManager
()
TypedQuery
<
CatalogEntry
>
dbQuery
=
db
Instance
.
getCurrentEntityManager
()
.
createQuery
(
sb
.
toString
(),
CatalogEntry
.
class
)
.
setParameter
(
"parentKey"
,
ce
.
getKey
())
.
setFirstResult
(
0
);
...
...
@@ -158,7 +157,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
sb
.
append
(
" order by cei."
).
append
(
orderBy
.
name
()).
append
(
asc
?
" ASC"
:
" DESC"
);
}
TypedQuery
<
CatalogEntryShort
>
dbQuery
=
DBFactory
.
get
Instance
()
.
getCurrentEntityManager
()
TypedQuery
<
CatalogEntryShort
>
dbQuery
=
db
Instance
.
getCurrentEntityManager
()
.
createQuery
(
sb
.
toString
(),
CatalogEntryShort
.
class
)
.
setParameter
(
"parentKey"
,
ce
.
getKey
())
.
setFirstResult
(
0
);
...
...
@@ -176,13 +175,19 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @return List of catalog entries of type CatalogEntry.TYPE_NODE
*/
public
List
<
CatalogEntry
>
getAllCatalogNodes
()
{
String
sqlQuery
=
"select cei from org.olat.catalog.CatalogEntryImpl as cei "
+
" where cei.type= :type "
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setInteger
(
"type"
,
CatalogEntry
.
TYPE_NODE
);
// cache this query
dbQuery
.
setCacheable
(
true
);
return
dbQuery
.
list
();
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
"select cei from "
).
append
(
CatalogEntryImpl
.
class
.
getName
()).
append
(
" as cei "
)
.
append
(
" inner join fetch cei.ownerGroup as ownerGroup"
)
.
append
(
" left join fetch cei.repositoryEntry as repositoryEntry"
)
.
append
(
" left join fetch repositoryEntry.ownerGroup as repoOwnerGroup"
)
.
append
(
" left join fetch repositoryEntry.tutorGroup as repoTutorGroup"
)
.
append
(
" left join fetch repositoryEntry.participantGroup as repoParticipantGroup"
)
.
append
(
" where cei.type= :type"
);
return
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
sb
.
toString
(),
CatalogEntry
.
class
)
.
setParameter
(
"type"
,
CatalogEntry
.
TYPE_NODE
)
.
getResultList
();
}
...
...
@@ -211,14 +216,14 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
query
.
append
(
" and cei.type=:type"
);
}
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
query
.
toString
());
dbQuery
.
setLong
(
"parentKey"
,
ce
.
getKey
());
TypedQuery
<
Number
>
dbQuery
=
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
query
.
toString
(),
Number
.
class
)
.
setParameter
(
"parentKey"
,
ce
.
getKey
());
if
(
type
>=
0
)
{
dbQuery
.
set
Integ
er
(
"type"
,
type
);
dbQuery
.
set
Paramet
er
(
"type"
,
type
);
}
// cache this query
dbQuery
.
setCacheable
(
true
);
Number
totalCount
=
(
Number
)
dbQuery
.
uniqueResult
();
Number
totalCount
=
dbQuery
.
getSingleResult
();
return
totalCount
.
intValue
();
}
...
...
@@ -230,8 +235,6 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*/
public
List
<
CatalogEntry
>
filterOwnedLeafs
(
Identity
identity
,
List
<
CatalogEntry
>
catalogEntries
)
{
List
<
CatalogEntry
>
ownedEntries
=
new
ArrayList
<
CatalogEntry
>();
BaseSecurity
securityManager
=
BaseSecurityManager
.
getInstance
();
for
(
CatalogEntry
cate:
catalogEntries
)
{
if
(
cate
.
getType
()
==
CatalogEntry
.
TYPE_LEAF
)
{
RepositoryEntry
repe
=
cate
.
getRepositoryEntry
();
...
...
@@ -251,7 +254,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @return reloaded catalog entry
*/
public
CatalogEntry
loadCatalogEntry
(
CatalogEntry
catalogEntry
)
{
return
(
CatalogEntry
)
DBFactory
.
getInstance
().
loadObject
(
catalogEntry
);
return
dbInstance
.
getCurrentEntityManager
().
find
(
CatalogEntryImpl
.
class
,
catalogEntry
.
getKey
()
);
}
/**
...
...
@@ -260,7 +263,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @return
*/
public
CatalogEntry
loadCatalogEntry
(
Long
catEntryId
)
{
return
(
CatalogEntry
)
DBFactory
.
getInstance
().
loadObject
(
CatalogEntryImpl
.
class
,
catEntryId
);
return
dbInstance
.
getCurrentEntityManager
().
find
(
CatalogEntryImpl
.
class
,
catEntryId
);
}
/**
...
...
@@ -269,7 +272,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param ce
*/
public
void
saveCatalogEntry
(
CatalogEntry
ce
)
{
DBFactory
.
getInstance
().
saveObjec
t
(
ce
);
dbInstance
.
getCurrentEntityManager
().
persis
t
(
ce
);
}
/**
...
...
@@ -278,35 +281,9 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param ce
*/
public
CatalogEntry
updateCatalogEntry
(
CatalogEntry
ce
)
{
DBFactory
.
getInstance
().
updateObject
(
ce
);
return
ce
;
return
dbInstance
.
getCurrentEntityManager
().
merge
(
ce
);
}
public
List
entriesWithOwnerFrom
(
Identity
owner
,
CatalogEntry
ce
)
{
List
retVal
=
new
ArrayList
();
findEntriesOf
(
owner
,
ce
,
retVal
);
return
retVal
;
}
private
void
findEntriesOf
(
Identity
owner
,
CatalogEntry
root
,
List
entries
)
{
/*
* check if node is owned by identity
*/
BaseSecurity
secMgr
=
BaseSecurityManager
.
getInstance
();
SecurityGroup
owners
=
root
.
getOwnerGroup
();
if
(
owners
!=
null
&&
secMgr
.
isIdentityInSecurityGroup
(
owner
,
owners
))
{
entries
.
add
(
root
);
}
/*
* check subtree, by visit children first strategy
*/
List
children
=
getChildrenOf
(
root
);
Iterator
iter
=
children
.
iterator
();
while
(
iter
.
hasNext
())
{
CatalogEntry
nextCe
=
(
CatalogEntry
)
iter
.
next
();
findEntriesOf
(
owner
,
nextCe
,
entries
);
}
}
/**
* delete a catalog entry and a potentially referenced substructure from db.
* Be aware of how to use this deletion, as all the referenced substructure is
...
...
@@ -315,18 +292,19 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param ce
*/
public
void
deleteCatalogEntry
(
CatalogEntry
ce
)
{
getLogger
().
debug
(
"deleteCatalogEntry start... ce="
+
ce
);
BaseSecurity
securityManager
=
BaseSecurityManager
.
getInstance
();
boolean
debug
=
isLogDebugEnabled
();
if
(
debug
)
logDebug
(
"deleteCatalogEntry start... ce="
+
ce
);
if
(
ce
.
getType
()
==
CatalogEntry
.
TYPE_LEAF
)
{
//delete catalog entry, then delete owner group
SecurityGroup
owner
=
ce
.
getOwnerGroup
();
DBFactory
.
getInstance
().
deleteObject
(
ce
);
dbInstance
.
getCurrentEntityManager
().
remove
(
ce
);
if
(
owner
!=
null
)
{
getLogger
().
debug
(
"deleteCatalogEntry case_1: delete owner-group="
+
owner
);
securityManager
.
deleteSecurityGroup
(
owner
);
}
}
else
{
List
secGroupsToBeDeleted
=
new
ArrayList
();
List
<
SecurityGroup
>
secGroupsToBeDeleted
=
new
ArrayList
<
SecurityGroup
>
();
//FIXME pb: the transaction must also include the deletion of the security
// groups. Why not using this method as a recursion and seperating the
// deletion of the ce and the groups by collecting the groups? IMHO there
...
...
@@ -338,13 +316,13 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
// not a problem, the DB object can handel this.
deleteCatalogSubtree
(
ce
,
secGroupsToBeDeleted
);
// after deleting all entries, delete all secGroups corresponding
for
(
Iterator
iter
=
secGroupsToBeDeleted
.
iterator
();
iter
.
hasNext
();)
{
for
(
Iterator
<
SecurityGroup
>
iter
=
secGroupsToBeDeleted
.
iterator
();
iter
.
hasNext
();)
{
SecurityGroup
grp
=
(
SecurityGroup
)
iter
.
next
();
getLogger
().
d
ebug
(
"deleteCatalogEntry case_2: delete groups of deleteCatalogSubtree grp="
+
grp
);
if
(
debug
)
logD
ebug
(
"deleteCatalogEntry case_2: delete groups of deleteCatalogSubtree grp="
+
grp
);
securityManager
.
deleteSecurityGroup
(
grp
);
}
}
getLogger
().
d
ebug
(
"deleteCatalogEntry END"
);
if
(
debug
)
logD
ebug
(
"deleteCatalogEntry END"
);
}
/**
...
...
@@ -352,24 +330,19 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*
* @param ce
*/
private
void
deleteCatalogSubtree
(
CatalogEntry
ce
,
List
secGroupsToBeDeleted
)
{
DB
db
=
DBFactory
.
getInstance
();
private
void
deleteCatalogSubtree
(
CatalogEntry
ce
,
List
<
SecurityGroup
>
secGroupsToBeDeleted
)
{
List
<
CatalogEntry
>
children
=
getChildrenOf
(
ce
);
Iterator
<
CatalogEntry
>
iter
=
children
.
iterator
();
while
(
iter
.
hasNext
())
{
CatalogEntry
nextCe
=
(
CatalogEntry
)
iter
.
next
();
for
(
CatalogEntry
nextCe:
children
)
{
deleteCatalogSubtree
(
nextCe
,
secGroupsToBeDeleted
);
}
ce
=
(
CatalogEntry
)
db
.
loadObject
(
ce
);
ce
=
dbInstance
.
getCurrentEntityManager
().
find
(
CatalogEntry
.
class
,
ce
.
getKey
()
);
//mark owner group for deletion.
SecurityGroup
owner
=
ce
.
getOwnerGroup
();
if
(
owner
!=
null
)
secGroupsToBeDeleted
.
add
(
owner
);
// delete user bookmarks
OLATResourceable
ores
=
createOLATResouceableFor
(
ce
);
//TODO bookmark BookmarkManager.getInstance().deleteAllBookmarksFor(ores);
// delete catalog entry itself
db
.
deleteObject
(
ce
);
if
(
owner
!=
null
)
{
secGroupsToBeDeleted
.
add
(
owner
);
}
//TODO delete marks
dbInstance
.
getCurrentEntityManager
().
remove
(
ce
);
}
/**
...
...
@@ -378,14 +351,14 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param repoEntry
* @return List of catalog entries
*/
public
List
getCatalogEntriesReferencing
(
RepositoryEntry
repoEntry
)
{
public
List
<
CatalogEntry
>
getCatalogEntriesReferencing
(
RepositoryEntry
repoEntry
)
{
String
sqlQuery
=
"select cei from "
+
" org.olat.catalog.CatalogEntryImpl as cei "
+
" ,org.olat.repository.RepositoryEntry as re "
+
" where cei.repositoryEntry = re AND re.key= :reKey "
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setCacheable
(
true
);
dbQuery
.
setLong
(
"reKey"
,
repoEntry
.
getKey
().
longValue
());
List
resSet
=
dbQuery
.
list
()
;
return
resSet
;
return
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
sqlQuery
,
CatalogEntry
.
class
)
.
setParameter
(
"reKey"
,
repoEntry
.
getKey
()
)
.
getResultList
()
;
}
/**
...
...
@@ -394,33 +367,18 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param repoEntry
* @return List of catalog entries
*/
public
List
getCatalogCategoriesFor
(
RepositoryEntry
repoEntry
)
{
public
List
<
CatalogEntry
>
getCatalogCategoriesFor
(
RepositoryEntry
repoEntry
)
{
String
sqlQuery
=
"select distinct parent from org.olat.catalog.CatalogEntryImpl as parent "
+
", org.olat.catalog.CatalogEntryImpl as cei "
+
", org.olat.repository.RepositoryEntry as re "
+
" where cei.repositoryEntry = re "
+
" and re.key= :reKey "
+
" and cei.parent = parent "
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setCacheable
(
true
);
dbQuery
.
setLong
(
"reKey"
,
repoEntry
.
getKey
().
longValue
());
List
resSet
=
dbQuery
.
list
();
return
resSet
;
}
/**
* find catalog entries by supplied name
*
* @param name
* @return List of catalog entries
*/
public
List
getCatalogEntriesByName
(
String
name
)
{
String
sqlQuery
=
"select cei from org.olat.catalog.CatalogEntryImpl as cei where cei.name = :name"
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setString
(
"name"
,
name
);
dbQuery
.
setCacheable
(
true
);
return
dbQuery
.
list
();
return
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
sqlQuery
,
CatalogEntry
.
class
)
.
setParameter
(
"reKey"
,
repoEntry
.
getKey
())
.
getResultList
();
}
public
CatalogEntry
getCatalogEntryByKey
(
Long
key
)
{
...
...
@@ -429,7 +387,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
.
append
(
" left join fetch cei.repositoryEntry as entry"
)
.
append
(
" where cei.key=:key"
);
List
<
CatalogEntry
>
entries
=
DBFactory
.
get
Instance
()
.
getCurrentEntityManager
()
List
<
CatalogEntry
>
entries
=
db
Instance
.
getCurrentEntityManager
()
.
createQuery
(
sb
.
toString
(),
CatalogEntry
.
class
)
.
setParameter
(
"key"
,
key
)
.
getResultList
();
...
...
@@ -449,14 +407,12 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
public
List
<
CatalogEntry
>
getCatalogEntriesOwnedBy
(
Identity
identity
)
{
String
sqlQuery
=
"select cei from org.olat.catalog.CatalogEntryImpl as cei inner join fetch cei.ownerGroup, "
+
" org.olat.basesecurity.SecurityGroupMembershipImpl as sgmsi"
+
" where "
+
" cei.ownerGroup = sgmsi.securityGroup and"
+
" sgmsi.identity = :identity"
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setEntity
(
"identity"
,
identity
);
dbQuery
.
setCacheable
(
true
);
return
dbQuery
.
list
();
" where cei.ownerGroup = sgmsi.securityGroup and sgmsi.identity.key = :identityKey"
;
return
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
sqlQuery
,
CatalogEntry
.
class
)
.
setParameter
(
"identityKey"
,
identity
.
getKey
())
.
getResultList
();
}
public
List
<
Identity
>
getOwnersOfParentLine
(
CatalogEntry
entry
)
{
...
...
@@ -489,10 +445,11 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param newEntry
*/
public
void
addCatalogEntry
(
CatalogEntry
parent
,
CatalogEntry
newEntry
)
{
getLogger
().
debug
(
"addCatalogEntry parent="
+
parent
);
boolean
debug
=
isLogDebugEnabled
();
if
(
debug
)
logDebug
(
"addCatalogEntry parent="
+
parent
);
newEntry
.
setParent
(
parent
);
getLogger
().
d
ebug
(
"addCatalogEntry newEntry="
+
newEntry
);
getLogger
().
d
ebug
(
"addCatalogEntry newEntry.getOwnerGroup()="
+
newEntry
.
getOwnerGroup
());
if
(
debug
)
logD
ebug
(
"addCatalogEntry newEntry="
+
newEntry
);
if
(
debug
)
logD
ebug
(
"addCatalogEntry newEntry.getOwnerGroup()="
+
newEntry
.
getOwnerGroup
());
saveCatalogEntry
(
newEntry
);
}
...
...
@@ -505,29 +462,27 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*/
public
List
<
CatalogEntry
>
getRootCatalogEntries
()
{
String
sqlQuery
=
"select cei from org.olat.catalog.CatalogEntryImpl as cei where cei.parent is null"
;
DBQuery
dbQuery
=
DBFactory
.
getInstance
().
createQuery
(
sqlQuery
);
dbQuery
.
setCacheable
(
true
);
return
dbQuery
.
l
ist
();
return
dbInstance
.
getCurrentEntityManager
()
.
createQuery
(
sqlQuery
,
CatalogEntry
.
class
)
.
getResultL
ist
();
}
/**
* init called on module start-up
*/
public
void
init
()
{
List
roots
=
getRootCatalogEntries
();
List
<
CatalogEntry
>
roots
=
getRootCatalogEntries
();
if
(
roots
.
isEmpty
())
{
// not initialized yet
//TODO inject via spring
BaseSecurity
secMgr
=
BaseSecurityManager
.
getInstance
();
/*
* copy a snapshot of olatAdmins into catalogAdmins do not put
* secMgr.findSecurityGroupByName(Constants.GROUP_ADMIN) directly into a
* CatalogEntry!!
*/
SecurityGroup
olatAdmins
=
sec
Mg
r
.
findSecurityGroupByName
(
Constants
.
GROUP_ADMIN
);
List
olatAdminIdents
=
sec
Mg
r
.
getIdentitiesOfSecurityGroup
(
olatAdmins
);
SecurityGroup
catalogAdmins
=
sec
Mg
r
.
createAndPersistSecurityGroup
();
SecurityGroup
olatAdmins
=
sec
urityManage
r
.
findSecurityGroupByName
(
Constants
.
GROUP_ADMIN
);
List
<
Identity
>
olatAdminIdents
=
sec
urityManage
r
.
getIdentitiesOfSecurityGroup
(
olatAdmins
);
SecurityGroup
catalogAdmins
=
sec
urityManage
r
.
createAndPersistSecurityGroup
();
for
(
int
i
=
0
;
i
<
olatAdminIdents
.
size
();
i
++)
{
sec
Mg
r
.
addIdentityToSecurityGroup
((
Identity
)
olatAdminIdents
.
get
(
i
),
catalogAdmins
);
sec
urityManage
r
.
addIdentityToSecurityGroup
((
Identity
)
olatAdminIdents
.
get
(
i
),
catalogAdmins
);
}
/*
* start with something called CATALOGROOT, you can rename it to whatever
...
...
@@ -535,7 +490,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*/
// parent == null -> no parent -> I am a root node.
saveCatEntry
(
CATALOGROOT
,
null
,
CatalogEntry
.
TYPE_NODE
,
catalogAdmins
,
null
,
null
);
DBFactory
.
get
Instance
(
false
)
.
intermediateCommit
();
db
Instance
.
intermediateCommit
();
}
}
...
...
@@ -559,10 +514,9 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* return true: success; false: failure
*/
public
boolean
moveCatalogEntry
(
CatalogEntry
toBeMovedEntry
,
CatalogEntry
newParentEntry
)
{
CatalogManager
cm
=
CatalogManager
.
getInstance
();
// reload current item to prevent stale object modification
toBeMovedEntry
=
cm
.
loadCatalogEntry
(
toBeMovedEntry
);
newParentEntry
=
cm
.
loadCatalogEntry
(
newParentEntry
);
toBeMovedEntry
=
loadCatalogEntry
(
toBeMovedEntry
);
newParentEntry
=
loadCatalogEntry
(
newParentEntry
);
// check that the new parent is not a leaf
if
(
newParentEntry
.
getType
()
==
CatalogEntry
.
TYPE_LEAF
)
return
false
;
// check that the new parent is not a child of the to be moved entry
...
...
@@ -576,7 +530,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
}
// set new parent and save
toBeMovedEntry
.
setParent
(
newParentEntry
);
cm
.
updateCatalogEntry
(
toBeMovedEntry
);
updateCatalogEntry
(
toBeMovedEntry
);
return
true
;
}
...
...
@@ -587,11 +541,11 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
public
void
resourceableDeleted
(
RepositoryEntry
repositoryEntry
)
{
// if a repository entry gets deleted, the referencing Catalog Entries gets
// retired to
getLogger
().
d
ebug
(
"sourceableDeleted start... repositoryEntry="
+
repositoryEntry
);
List
references
=
getCatalogEntriesReferencing
(
repositoryEntry
);
if
(
isLogDebugEnabled
())
logD
ebug
(
"sourceableDeleted start... repositoryEntry="
+
repositoryEntry
);
List
<
CatalogEntry
>
references
=
getCatalogEntriesReferencing
(
repositoryEntry
);
if
(
references
!=
null
&&
!
references
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
references
.
size
();
i
++)
{
deleteCatalogEntry
(
(
CatalogEntry
)
references
.
get
(
i
));
deleteCatalogEntry
(
references
.
get
(
i
));
}
}
}
...
...
@@ -604,18 +558,17 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*/
public
void
deleteUserData
(
Identity
identity
,
String
newDeletedUserName
)
{
// Remove as owner
List
catalogEntries
=
getCatalogEntriesOwnedBy
(
identity
);
for
(
Iterator
iter
=
catalogEntries
.
iterator
();
iter
.
hasNext
();)
{
CatalogEntry
catalogEntry
=
(
CatalogEntry
)
iter
.
next
();
List
<
CatalogEntry
>
catalogEntries
=
getCatalogEntriesOwnedBy
(
identity
);
for
(
CatalogEntry
catalogEntry:
catalogEntries
)
{
BaseS
ecurityManager
.
getInstance
().
removeIdentityFromSecurityGroup
(
identity
,
catalogEntry
.
getOwnerGroup
());
if
(
BaseS
ecurityManager
.
getInstance
().
countIdentitiesOfSecurityGroup
(
catalogEntry
.
getOwnerGroup
())
==
0
)
{
s
ecurityManager
.
removeIdentityFromSecurityGroup
(
identity
,
catalogEntry
.
getOwnerGroup
());
if
(
s
ecurityManager
.
countIdentitiesOfSecurityGroup
(
catalogEntry
.
getOwnerGroup
())
==
0
)
{
// This group has no owner anymore => add OLAT-Admin as owner
BaseS
ecurityManager
.
getInstance
().
addIdentityToSecurityGroup
(
UserDeletionManager
.
getInstance
().
getAdminIdentity
(),
catalogEntry
.
getOwnerGroup
());
Tracing
.
logInfo
(
"Delete user-data, add Administrator-identity as owner of catalogEntry="
+
catalogEntry
.
getName
()
,
this
.
getClass
()
);
s
ecurityManager
.
addIdentityToSecurityGroup
(
UserDeletionManager
.
getInstance
().
getAdminIdentity
(),
catalogEntry
.
getOwnerGroup
());
logInfo
(
"Delete user-data, add Administrator-identity as owner of catalogEntry="
+
catalogEntry
.
getName
());
}
}
Tracing
.
logDebug
(
"All owner entries in catalog deleted for identity="
+
identity
,
this
.
getClass
()
);
if
(
isLogDebugEnabled
())
logDebug
(
"All owner entries in catalog deleted for identity="
+
identity
);
}
/**
...
...
@@ -646,15 +599,7 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
*/
public
OLATResourceable
createOLATResouceableFor
(
final
CatalogEntry
currentCatalogEntry
)
{
if
(
currentCatalogEntry
==
null
)
return
null
;
return
new
OLATResourceable
()
{
public
Long
getResourceableId
()
{
return
new
Long
(
currentCatalogEntry
.
getKey
());
}
public
String
getResourceableTypeName
()
{
return
CATALOGENTRY
;
}
};
return
new
Resourceable
(
CATALOGENTRY
,
currentCatalogEntry
.
getKey
());
}
/**
...
...
@@ -662,10 +607,9 @@ public class CatalogManager extends BasicManager implements UserDataDeletable, I
* @param re
*/
public
void
updateReferencedRepositoryEntry
(
RepositoryEntry
re
)
{
RepositoryEntry
reloaded
=
R
epositoryManager
.
getInstance
().
setDescriptionAndName
(
re
,
re
.
getDisplayname
(),
re
.
getDescription
());
RepositoryEntry
reloaded
=
r
epositoryManager
.
setDescriptionAndName
(
re
,
re
.
getDisplayname
(),
re
.
getDescription
());
// inform anybody interested about this change
MultiUserEvent
modifiedEvent
=
new
EntryChangedEvent
(
reloaded
,
EntryChangedEvent
.
MODIFIED_DESCRIPTION
);
CoordinatorManager
.
getInstance
().
getCoordinator
().
getEventBus
().
fireEventToListenersOf
(
modifiedEvent
,
reloaded
);
}
}
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