This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 202063 - API review of a friend white list index
Summary: API review of a friend white list index
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Zezula
URL:
Keywords: API, API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2011-09-13 12:15 UTC by Tomas Zezula
Modified: 2011-09-20 13:12 UTC (History)
2 users (show)

See Also:
Issue Type: TASK
Exception Reporter:


Attachments
Diff file (59.75 KB, patch)
2011-09-13 12:24 UTC, Tomas Zezula
Details | Diff
Changed diff file (63.37 KB, patch)
2011-09-14 12:10 UTC, Tomas Zezula
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Zezula 2011-09-13 12:15:31 UTC
Added a persistent index of white list violations.
Use cases: Task list, Run on Web Project should warn if the project violates white list.
API stability: friend
Comment 1 Tomas Zezula 2011-09-13 12:24:58 UTC
Created attachment 110707 [details]
Diff file
Comment 2 Tomas Zezula 2011-09-13 12:25:39 UTC
Please review
Comment 3 David Konecny 2011-09-14 01:01:52 UTC
DK01 - thanks Tomas, looks good to me. The only thing I'm not sure about is whether WhiteListIndex is spi.whitelist.support or whether it would be more appropriate to be api.whitelist.index. It is API rather than SPI - the module builds index of whitelist violations and can return it to its clients like Java Editor or Web Project. My understanding of packages named "support" has always been that it is something optional which make API/SPI usage easier but everything could be as well achieve without it. In this case that's not true - spi.whitelist.support is the only way to access index.
Comment 4 Tomas Zezula 2011-09-14 08:38:14 UTC
DK01: For me it was rather spi.support as the callers were SPI implementors like TaskListProvider, HintProvider. But I have no problem move it into api as the border among API and SPI in this case is very thin. So the new package will be o.n.api.whitelist.index. I don't want to have it directly in o.n.api.whitelist as it's not the "core" API. Ideally it should be separated into 2 packages. The first index holding the WhiteListIndexListener, WhiteListIndexEvent and WhiteListIndex without the Map<? extends Tree, ? extends WhiteListQuery.Result> getWhiteListViolations(...) method as it's a support method. And support package having a support class with a single static method Map<? extends Tree, ? extends WhiteListQuery.Result> getWhiteListViolations(...). But it will introduce package with single class having just one static method.
Comment 5 Tomas Zezula 2011-09-14 12:03:52 UTC
I've changed it as I've described in the ideal solution.
Separated into 2 packages. The first index holding the WhiteListIndexListener,
WhiteListIndexEvent and WhiteListIndex without the Map<? extends Tree, ?
extends WhiteListQuery.Result> getWhiteListViolations(...) method as it's a
support method. And support package having a support class with a single static
method Map<? extends Tree, ? extends WhiteListQuery.Result>
getWhiteListViolations(...).
Comment 6 Tomas Zezula 2011-09-14 12:10:45 UTC
Created attachment 110745 [details]
Changed diff file
Comment 7 David Konecny 2011-09-14 21:15:22 UTC
Thanks Tomas, looks OK to me.
Comment 8 David Konecny 2011-09-15 03:06:48 UTC
In offline discussion with Tomas we have agree on two other small changes:

#1) add a variation of WhiteListIndex.getWhiteListViolations method which accepts whitelist ID:

public Collection<? extends Problem> getWhiteListViolations(
        @NonNull final FileObject root,
        @NullAllowed final FileObject file,
        @NonNull final String whitelistID) 
    throws IllegalArgumentException, UnsupportedOperationException {

Such method will be used in cases when client wants to query all problems from certain whitelist only.

#2) split current final Result class into two final classes to support merging of whitelist results. This will mean that existing public signature :

class Result {
  Result(boolean allowed, String violatedRuleName, String violatedRuleDesc)
  boolean isAllowed()
  String getViolatedRuleDescription()
  String getViolatedRuleName()
}

will change into:

class Result {
  Result(boolean allowed, List<RuleDescription> violatedRules)
  boolean isAllowed()
  List<RuleDescription> getViolatedRules()
}
class RuleDescription {
  RuleDescription(String ruleName, String ruleDesc, String whiteListID)
  String getRuleName()
  String getRuleDescription()
  String getWhiteListID()
}

Tomas please confirm that I got it right. Thanks.
Comment 9 Tomas Zezula 2011-09-15 13:50:53 UTC
Yes.
Just minor change from:

public Collection<? extends Problem> getWhiteListViolations(
        @NonNull final FileObject root,
        @NullAllowed final FileObject file,
        @NonNull final String whitelistID) 
    throws IllegalArgumentException, UnsupportedOperationException {

to:

public Collection<? extends Problem> getWhiteListViolations(
        @NonNull final FileObject root,
        @NullAllowed final FileObject file,
        @NonNull final String... whitelists) 
    throws IllegalArgumentException, UnsupportedOperationException {


And maybe the Result constructor:
Result(boolean allowed, List<RuleDescription> violatedRules)

should be splited into:

Result(List<RuleDescription> violatedRules) -> isAllowed false with given violations
Result() -> isAllowed true
Comment 10 Tomas Zezula 2011-09-15 13:52:12 UTC
So I am integrating the WhiteListIndex and WhiteListSupport (including the whitelists parameter in the getWhiteListViolations)
Comment 11 Tomas Zezula 2011-09-15 14:31:38 UTC
I've fille a separate issue for point 2 (WhiteListQuery.Result change) as it affects different class and it's incompatible change. The issue #202187
Comment 12 Tomas Zezula 2011-09-15 14:32:16 UTC
Fixed jet-main a7c56f42d43d
Comment 13 Quality Engineering 2011-09-17 14:12:26 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/a7c56f42d43d
User: Tomas Zezula <tzezula@netbeans.org>
Log: #202063:API review of a friend white list index
Comment 14 Jesse Glick 2011-09-20 12:19:20 UTC
(In reply to comment #3)
> My understanding of packages named "support" has always
> been that it is something optional which make API/SPI usage easier but
> everything could be as well achieve[d] without it.

Right, that is the intention of the name. More formally, it should be possible to make a *.support package nonpublic by doing a copy refactoring of its contents (and any transitive nonpublic dependencies) into each module currently calling it. That is not the case in general for an API or SPI.
Comment 15 Tomas Zezula 2011-09-20 13:12:34 UTC
In reply to comment #14
The packaging is OK from this point of view. The WhiteListIndex is in o.n.a.whitelist.index and WhiteListSupport (holding only support method) is in o.n.a.whitelist.support.