Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@irinaepshteyn
Copy link
Collaborator

@irinaepshteyn irinaepshteyn commented Feb 23, 2017

No description provided.

@irinaepshteyn
Copy link
Collaborator Author

@@ -0,0 +1,29 @@
package com.ge.predix.acs.attribute.connectors;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove extra space

@Autowired
private DefaultSubjectAttributeReader defaultSubjectAttributeReader;

private AttributeReader resourceAttributeReader;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No setters or getters and also not wiring the bean, how will we use the resourceAttributeReader?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to construct resourceAttributeReader based on zone configuration read from the database.

private AttributeReader resourceAttributeReader;
private SubjectAttributeReader subjectAttributeReader;

public AttributeReader getResourceAttributeReader(final String zoneId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this zoneId as an argument a stub for when we will lookup the which attributeReader to use from the persistent store?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we are ready to persist zone configuration, zoneId will be used to read zone configuration from the database

private PolicySetValidator policySetValidator;
@Autowired
private ZoneResolver zoneResolver;
@Autowired
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ZoneConfiguration or ZoneId can be directly loaded from spring authentication, This will avoid any changes to higher layers and pushing this info downstream.
((ZoneOAuth2Authentication) SecurityContextHolder.getContext().getAuthentication()).getZoneId()

import com.ge.predix.acs.model.Attribute;

@Component
public class InMemoryAttributeStore {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is unnecessary - InMemoryStoreAdapter can simply hold a map within it.


import com.ge.predix.acs.model.Attribute;

public class InMemoryAttributeStoreAdapter implements AttributeStoreAdapter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In hindsight, because the adapter really belongs outside ACS, this story should just have the initial CustomResourceAttributeReader return a fixed set of attributes. (Or the policy evaluation test can mock the attributeReader)
The key part of this story is the Evaluation test you, wrote and changes in evaluation code path to use a CustomResourceAttributeReader


import com.ge.predix.acs.model.Attribute;

public class CustomResourceAttributeReader implements AttributeReader {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more thoughts on naming :)
AttributeReader is how its consumers use it. The classes which implement them can be different things. e.g.

  • ResourceAttributeConnector implements AttributeReader
  • PrivilegeManagementServiceImpl implements PrivilegeManagementService, AttributeReader, SubjectAttributeReader (this also means we can get rid of DefaultSubjectAttributeReader and DefaultResourceAttributeReader)

import org.springframework.stereotype.Component;

@Component
public class ZoneConfiguration {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration will be fleshed out in the next story - most likely these 2 fields will become part of ZoneEntity class, and link to a ConnectorConfiguration JPAEntity.


public interface AttributeReader {
Set<Attribute> getAttributes(String identifier);
Set<Attribute> getAttributes(final String identifier);
Copy link
Contributor

@anubhavi25 anubhavi25 Feb 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concrete classes implementing interface methods should declare the parameters as final so this is a redundant use of it. This is also supposed to be enforced by our CheckStyle rules via the RedundantModifier module but it's not due to a bug in the version of CheckStyle we're using. As part of DE22352 I've updated to the latest version of CheckStyle on the develop branch so please rebase this branch onto develop and rebuild; once you do so you'll see this issue being flagged properly.

import com.ge.predix.acs.model.Attribute;

public interface AttributeStoreAdapter {
Set<Attribute> getAttributes(final String identifier);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment re. redundant use of final in interface methods


public interface SubjectAttributeReader extends AttributeReader {
Set<Attribute> getAttributesByScope(String identifier, Set<Attribute> scopes);
Set<Attribute> getAttributesByScope(final String identifier, final Set<Attribute> scopes);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment re. redundant use of final in interface methods

@irinaepshteyn irinaepshteyn changed the title US77587: Added attribute reader and adapter for in-memory attribute s… US77587: Added attribute reader factory and connector to arbitrary attribute store Feb 26, 2017
@@ -0,0 +1,5 @@
package com.ge.predix.acs.attribute.connectors;

public interface ResourceAttributeReader extends AttributeReader {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we anticipate adding more functionality to this interface in the immediate future?

If so, maybe put a comment saying that it shouldn't be refactored out?

If not, should we delete this interface and replace implements ResourceAttributeReader with implements AttributeReader everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to be explicit for code readability

Copy link
Contributor

@sanjeevchopra sanjeevchopra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@irinaepshteyn this branch is ready for merge, imo. please review.

@sanjeevchopra sanjeevchopra merged commit 7ad86a3 into develop Feb 28, 2017
@sanjeevchopra sanjeevchopra deleted the US77587 branch March 27, 2017 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants