Skip to content

Commit a63ab8c

Browse files
committed
Merge remote-tracking branch 'upstream/master' into travis_update
2 parents ae57549 + 615d3f8 commit a63ab8c

File tree

67 files changed

+3006
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+3006
-334
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ language: java
22
jdk:
33
- openjdk7
44
- oraclejdk8
5+
before_install:
6+
- cp ./settings.xml ~/.m2/
57
after_success:
68
- '[[ $TRAVIS_BRANCH == "master" ]] && [[ $TRAVIS_JDK_VERSION == "openjdk7" ]] &&
79
{ mvn clean deploy -DskipTests; };'

COPYING renamed to LICENSE

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
631631
state the exclusion of warranty; and each file should have at least
632632
the "copyright" line and a pointer to where the full notice is found.
633633

634-
<one line to give the program's name and a brief idea of what it does.>
635-
Copyright (C) <year> <name of author>
634+
lightblue: Cloud focused data services with dynamic querying, versioned schemas, and robust security.
635+
Copyright (C) 2013 lightblue Contributors
636636

637637
This program is free software: you can redistribute it and/or modify
638638
it under the terms of the GNU General Public License as published by
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
652652
If the program does terminal interaction, make it output a short
653653
notice like this when it starts in an interactive mode:
654654

655-
<program> Copyright (C) <year> <name of author>
655+
lightblue Copyright (C) 2013 lightblue Contributors
656656
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657657
This is free software, and you are welcome to redistribute it
658658
under certain conditions; type `show c' for details.

README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
[![Build Status](https://travis-ci.org/lightblue-platform/lightblue-ldap.svg?branch=master)](https://travis-ci.org/lightblue-platform/lightblue-ldap) [![Coverage Status](https://coveralls.io/repos/lightblue-platform/lightblue-ldap/badge.png?branch=master)](https://coveralls.io/r/lightblue-platform/lightblue-ldap?branch=master) [![Stories in Ready](https://badge.waffle.io/lightblue-platform/lightblue-ldap.svg?label=ready&title=Ready)](http://waffle.io/lightblue-platform/lightblue-ldap)
2+
3+
# Books!
4+
5+
* [Overview](http://jewzaam.gitbooks.io/lightblue/)
6+
* [User Guide](http://jewzaam.gitbooks.io/lightblue-user-guide/)
7+
* [Developer Manual](http://jewzaam.gitbooks.io/lightblue-developer-manual/)
8+
9+
10+
# lightblue
11+
12+
Cloud focused data services with dynamic querying, versioned schemas, and robust security.
13+
14+
![lightblue architecture](https://raw.githubusercontent.com/lightblue-platform/lightblue/master/docs/lightblue-puzzle.png "High Level Architecture")
15+
16+
## Why lightblue?
17+
18+
Developing enterprise services for access to data (CRUD) can be deceptively simple. Just write something that gives access to the data you need. Done! The challenge is how do to deal with growth over time and not replicate the data access layer for every component.
19+
20+
### Why is it so hard to add a new field?
21+
* Adding a field may break backwards compatibility for clients of a service.
22+
* Updating all service clients is not easy to schedule.
23+
* Adding new APIs on the service solves the above problems but leads to sprawling APIs and inconsistency.
24+
25+
### Can we move our data to MongoDB?
26+
* Migrating from one type of tech to another is not trivial, such as RDBMS to NoSQL.
27+
* Moving some proprietary database technologies outside of a traditional datastore can be very costly.
28+
* Changes in underlying datastore will lead to optimized ways accessing the data. This changes APIs!
29+
30+
### Why is Information Security so concerned with moving to a cloud provider?
31+
* When you control your data and application tier hardware it is easy to be lax with security.
32+
* Moving data and applications off of hardware you control requires robust security.
33+
* Enabling the move to public API access to even sensitive data requires a lot of rigor.
34+
35+
### Do more with less!
36+
* IT budgets are shrinking while business demands continue to rise. Any place cost can be reduced relative to gains is great!
37+
38+
### How does lightblue benefit developers?
39+
One of the time sinks for developers is adding new features for clients of their software. To address this for data access, lightblue provides a robust and very capable API, supports a growing number of datastores, and enables changes to data models without impacting existing clients through the use of versioned metadata.
40+
41+
#### Robust API
42+
The REST API of lightblue is designed to do everything a client could want. There are some key points that the API addresses:
43+
* Query: a very rich query language
44+
* Projection: return only the data a client wants
45+
* Bulk Operations: ability execute CRUD operations against many records or entire collections
46+
47+
#### Datastore Agnostic
48+
Clients do not care where data is stored as long as it is available and secure. With lightblue we have controller implementations for:
49+
* MongoDB (1.9.0 and higher)
50+
* RDBMS (ANSI SQL92)
51+
52+
Not seeing a contoller you need? We welcome new implementations and contributions in general! From opening a request for enhancement to writing code, your ideas and help are greatly appricated.
53+
54+
#### Versioned Metadata
55+
All data in lightblue is controlled by its metadata. Think of this as all the DDL for a table in a relational database.
56+
A specific version of this metadata provides a view of the stored data. You can have many versions of metadata active at a time, providing different clients with different views of this data. Key points to remember:
57+
* all data structures are captured as metadata
58+
* each data stucture can have multiple versions active at a time
59+
* each client deals with data of a specific version
60+
* clients using different versions are seeing the same data, just viewed through a different window
61+
62+
<insert example, something simple that anybody can relate to>
63+
64+
### How does lightblue benefit operations?
65+
One of the challenges with maintaining enterprise applications is ensuring they are always on. When any change to a data structure requires application deployments it requires operations resources and can require outages to execute. With lightblue any changes to a data structure is simply a change to metadata.
66+
* metadata updates are not software changes
67+
* metadata updates are guarenteed backwards compatible
68+
69+
Example workflow to update a single field without lightblue:
70+
![Slow](https://raw.github.com/lightblue-platform/lightblue/master/docs/slow.png)
71+
72+
Example workflow to update a single field *with* lightblue:
73+
![Fast](https://raw.github.com/lightblue-platform/lightblue/master/docs/fast.png)
74+
75+
Some other benefits beyond simply reducing operations overhead are:
76+
* lightblue is designed to be deployed anywhere
77+
* lightblue employes a flexible component architecture that enables components to be deployed and scaled independently
78+
* lightblue is built to be both latency and fault tollerant
79+
* lightblue works with your preference of authentication and authorization
80+
81+
### What about support and development tools?
82+
If lightblue enables data access across many datasources and technologies we also need to provide tools to support that stack! Enter the management applications:
83+
* Metadata Management Application
84+
* Data Management Application
85+
86+
![Lightblue Applications](https://raw.githubusercontent.com/lightblue-platform/lightblue/master/docs/overview.png)
87+
88+
Each of the applications provides access to the corresponding service layer. The point of them is provide a nicer interface to the service layer without having to deal with the service directly. Each application can be secured independent of the service tier, as noted in the diagram.
89+
90+
## See lightblue in action!
91+
* Deploy lightblue on OpenShift: [openshift-lightblue-all](https://github.com/lightblue-platform/openshift-lightblue-all)
92+
* Deploy lightblue with basic-auth:
93+
* Deploy lightblue with SAML 2.0:
94+
95+
# License
96+
97+
The license of lightblue is [GPLv3](https://www.gnu.org/licenses/gpl.html). See LICENSE in root of project for the full text.
98+
99+
# Dependencies
100+
101+
| Dependency | Why | License
102+
| ---------- | --- | -------
103+
| [Jackson](http://wiki.fasterxml.com/JacksonHome) | Java library for processing JSON documents. Use in complicated cases where processing is required on the JSON document. |[Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
104+
| [JSONassert](https://github.com/skyscreamer/JSONassert) | Used in unit tests to compare JSON documents before and after processing. Useful for verifying parsing and type conversions (JSON -> Java -> JSON for example) | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
105+
| [json-schema-validator](https://github.com/fge/json-schema-validator) | Validation of JSON documents against a JSON schema. Similar to XML Schema validation. | [LGPLv3 or later](https://www.gnu.org/licenses/lgpl.html)
106+
| [Flapdoodle Embedded MongoDB](https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo) | In memory MongoDB used in unit tests to test against a real database. | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
107+
| [mongo-java-driver](https://github.com/mongodb/mongo-java-driver) | MongoDB driver for Java. Used for all interactions with MongoDB from Java. | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
108+
| [hystrix](https://github.com/Netflix/Hystrix) et al.| Hystrix core is a java framework to build a Distributed/Cloud-enabled Systems. It's "... is a latency and fault tolerance library designed to isolate points. .., stop cascading failure and enable resilience ...". | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
109+
| [pyresttest](https://github.com/svanoort/pyresttest)| Python utility for testing and benchmarking RESTful services. | [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)

lightblue-ldap-common/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<dependencies>
3434
<dependency>
3535
<groupId>com.redhat.lightblue</groupId>
36-
<artifactId>metadata</artifactId>
36+
<artifactId>lightblue-core-metadata</artifactId>
3737
</dependency>
3838

3939
<dependency>

lightblue-ldap-common/src/main/java/com/redhat/lightblue/common/ldap/DBResolver.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@
2222
import com.unboundid.ldap.sdk.LDAPConnection;
2323
import com.unboundid.ldap.sdk.LDAPException;
2424

25-
25+
/**
26+
* House and maintain connections to LDAP for the various {@link DataStore} instances.
27+
*
28+
* @author dcrissman
29+
*/
2630
public interface DBResolver {
2731

2832
/**
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2014 Red Hat, Inc. and/or its affiliates.
2+
Copyright 2015 Red Hat, Inc. and/or its affiliates.
33
44
This file is part of lightblue.
55
@@ -16,21 +16,19 @@
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <http://www.gnu.org/licenses/>.
1818
*/
19-
package com.redhat.lightblue.metadata.ldap.parser;
19+
package com.redhat.lightblue.common.ldap;
2020

21-
import com.redhat.lightblue.metadata.parser.MetadataParser;
22-
import com.redhat.lightblue.metadata.parser.PropertyParser;
23-
24-
public class LdapPropertyParser <T> extends PropertyParser<T> {
25-
26-
public Object parse(String name, MetadataParser<T> p, T node) {
27-
// TODO Auto-generated method stub
28-
return null;
29-
}
21+
/**
22+
* LDAP specific constants
23+
*
24+
* @author dcrissman
25+
*/
26+
public final class LdapConstant {
3027

31-
public void convert(MetadataParser<T> p, T emptyNode, Object object) {
32-
// TODO Auto-generated method stub
28+
public static final String BACKEND = "ldap";
29+
public static final String FIELD_DN = "dn";
30+
public static final String FIELD_OBJECT_CLASS = "objectClass";
3331

34-
}
32+
private LdapConstant(){}
3533

3634
}

lightblue-ldap-common/src/main/java/com/redhat/lightblue/common/ldap/LdapDataStore.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,21 @@
2020

2121
import com.redhat.lightblue.metadata.DataStore;
2222

23+
/**
24+
* {@link DataStore} for LDAP.
25+
*
26+
* @author dcrissman
27+
*/
2328
public class LdapDataStore implements DataStore {
2429

2530
private static final long serialVersionUID = 7599798419158041647L;
2631

27-
public static final String BACKEND = "ldap";
28-
2932
private String database;
3033
private String baseDN;
3134
private String uniqueField;
3235

3336
public String getBackend() {
34-
return BACKEND;
37+
return LdapConstant.BACKEND;
3538
}
3639

3740
public String getDatabase() {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/*
2+
Copyright 2015 Red Hat, Inc. and/or its affiliates.
3+
4+
This file is part of lightblue.
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation, either version 3 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License
17+
along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
package com.redhat.lightblue.common.ldap;
20+
21+
import com.redhat.lightblue.metadata.ArrayField;
22+
import com.redhat.lightblue.metadata.Field;
23+
import com.redhat.lightblue.metadata.Fields;
24+
25+
/**
26+
* Utility methods to assist with interacting with the Lightblue framework.
27+
*
28+
* @author dcrissman
29+
*/
30+
public final class LightblueUtil {
31+
32+
public static final String FIELD_OBJECT_TYPE = "objectType";
33+
public static final String FIELD_ARRAY_COUNT_POSTFIX = "#";
34+
35+
/**
36+
* Returns <code>true</code> if the passed in field name is the object type, otherwise <code>false</code>.
37+
* @param fieldName - field name to test.
38+
* @return <code>true</code> if the passed in field name is the object type, otherwise <code>false</code>.
39+
*/
40+
public static boolean isFieldObjectType(String fieldName){
41+
if(fieldName == null){
42+
return false;
43+
}
44+
45+
return FIELD_OBJECT_TYPE.equalsIgnoreCase(fieldName);
46+
}
47+
48+
/**
49+
* Returns <code>true</code> if the passed in field name matches the array count field name pattern,
50+
* otherwise <code>false</code>.
51+
* @param fieldName - field name to test.
52+
* @return <code>true</code> if the passed in field name matches the array count field name pattern,
53+
* otherwise <code>false</code>.
54+
*/
55+
protected static boolean doesFieldNameMatchArrayCountPattern(String fieldName){
56+
if(fieldName == null){
57+
return false;
58+
}
59+
return fieldName.endsWith(FIELD_ARRAY_COUNT_POSTFIX);
60+
}
61+
62+
/**
63+
* Returns <code>true</code> if the passed in field name is the count field for an array field,
64+
* otherwise <code>false</code>.
65+
* @param fieldName - field name to test.
66+
* @param metadataFields - {@link Fields} from entity metadata.
67+
* @return <code>true</code> if the passed in field name is the count field for an array field,
68+
* otherwise <code>false</code>.
69+
*/
70+
public static boolean isFieldAnArrayCount(String fieldName, Fields metadataFields){
71+
if(!doesFieldNameMatchArrayCountPattern(fieldName)){
72+
return false;
73+
}
74+
75+
Field field = metadataFields.getField(createArrayFieldNameFromCountField(fieldName));
76+
if((field != null) && (field instanceof ArrayField)){
77+
return true;
78+
}
79+
80+
return false;
81+
}
82+
83+
/**
84+
* Created and returns the name of the array count field for the passed in array field name.
85+
* @param arrayFieldName - array field name.
86+
* @return name of the array count field for the passed in array field name.
87+
*/
88+
public static String createArrayCountFieldName(String arrayFieldName){
89+
return arrayFieldName + FIELD_ARRAY_COUNT_POSTFIX;
90+
}
91+
92+
/**
93+
* Creates and returns the array field name for the passed in array count field name.
94+
* @param countField - array count field.
95+
* @return the array field name for the passed in array count field name.
96+
*/
97+
public static String createArrayFieldNameFromCountField(String countField){
98+
if(countField == null){
99+
return null;
100+
}
101+
if(!doesFieldNameMatchArrayCountPattern(countField)){
102+
return countField;
103+
}
104+
return countField.substring(0, countField.length() - 1);
105+
}
106+
107+
private LightblueUtil(){}
108+
109+
}

lightblue-ldap-common/src/test/java/com/redhat/lightblue/common/ldap/LdapDataStoreTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class LdapDataStoreTest {
2626

2727
@Test
2828
public void testGetBackend(){
29-
assertEquals(LdapDataStore.BACKEND, new LdapDataStore().getBackend());
29+
assertEquals(LdapConstant.BACKEND, new LdapDataStore().getBackend());
3030
}
3131

3232
}

0 commit comments

Comments
 (0)