Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
3ec010e7
Commit
3ec010e7
authored
14 years ago
by
cramakri
Browse files
Options
Downloads
Patches
Plain Diff
LMS-1544 Added collection predicate to more efficiently check a collection.
SVN: 16134
parent
b95a5b74
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
openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/authorization/predicate/SampleOwnerIdentifierCollectionPredicate.java
+95
-0
95 additions, 0 deletions
...n/predicate/SampleOwnerIdentifierCollectionPredicate.java
with
95 additions
and
0 deletions
openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/authorization/predicate/SampleOwnerIdentifierCollectionPredicate.java
0 → 100644
+
95
−
0
View file @
3ec010e7
/*
* Copyright 2008 ETH Zuerich, CISD
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
ch.systemsx.cisd.openbis.generic.shared.authorization.predicate
;
import
java.util.List
;
import
ch.systemsx.cisd.common.exceptions.Status
;
import
ch.systemsx.cisd.openbis.generic.shared.authorization.IAuthorizationDataProvider
;
import
ch.systemsx.cisd.openbis.generic.shared.authorization.RoleWithIdentifier
;
import
ch.systemsx.cisd.openbis.generic.shared.authorization.annotation.ShouldFlattenCollections
;
import
ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE
;
import
ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleOwnerIdentifier
;
/**
* An <code>IPredicate</code> implementation based on {@link SampleOwnerIdentifier}.
*
* @author Chandrasekhar Ramakrishnan
*/
@ShouldFlattenCollections
(
value
=
false
)
public
final
class
SampleOwnerIdentifierCollectionPredicate
extends
AbstractPredicate
<
List
<
SampleOwnerIdentifier
>>
{
private
final
SpaceIdentifierPredicate
spacePredicate
;
private
final
DatabaseInstanceIdentifierPredicate
databaseInstanceIdentifierPredicate
;
public
SampleOwnerIdentifierCollectionPredicate
()
{
this
(
true
);
}
public
SampleOwnerIdentifierCollectionPredicate
(
boolean
isReadAccess
)
{
spacePredicate
=
new
SpaceIdentifierPredicate
();
databaseInstanceIdentifierPredicate
=
new
DatabaseInstanceIdentifierPredicate
(
isReadAccess
);
}
//
// AbstractPredicate
//
public
final
void
init
(
IAuthorizationDataProvider
provider
)
{
spacePredicate
.
init
(
provider
);
databaseInstanceIdentifierPredicate
.
init
(
provider
);
}
@Override
public
final
String
getCandidateDescription
()
{
return
"sample identifier"
;
}
@Override
final
Status
doEvaluation
(
final
PersonPE
person
,
final
List
<
RoleWithIdentifier
>
allowedRoles
,
final
List
<
SampleOwnerIdentifier
>
values
)
{
for
(
SampleOwnerIdentifier
value
:
values
)
{
if
(
value
.
isDatabaseInstanceLevel
())
{
Status
result
=
databaseInstanceIdentifierPredicate
.
doEvaluation
(
person
,
allowedRoles
,
value
.
getDatabaseInstanceLevel
());
if
(
Status
.
OK
!=
result
)
{
return
result
;
}
}
else
{
Status
result
=
spacePredicate
.
doEvaluation
(
person
,
allowedRoles
,
value
.
getSpaceLevel
());
if
(
Status
.
OK
!=
result
)
{
return
result
;
}
}
}
return
Status
.
OK
;
}
}
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