Skip to content

Commit

Permalink
[FAB-6637] add license check to fabric-chaincode-java
Browse files Browse the repository at this point in the history
for source files in SourceSets:
+ change copyrights `DTCC 2016` -> `IBM Corp., DTCC`
+ change copyrights `IBM 2017` -> `IBM Corp.`

add gradle licenseCheck task for build task to depend on

Change-Id: If4acc8d45b4e57817b81474fa2788e649cbc5693
Signed-off-by: Jingxiao Gu <[email protected]>
  • Loading branch information
Jingxiao Gu committed Oct 19, 2017
1 parent 9f2f4f9 commit 64de43a
Show file tree
Hide file tree
Showing 36 changed files with 204 additions and 506 deletions.
57 changes: 57 additions & 0 deletions shim/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,60 @@ publishing {
}
}
}

task licenseCheck {
group = "license"
description = "Checks the License part of each source file"

println "Checking Licences..."
def noSPDX = new LinkedList<File>()
def missing = new LinkedList<File>()
sourceSets.forEach {
sourceSet ->
sourceSet.allSource.findAll { !it.path.contains("build") }.each {
file ->
BufferedReader r = new BufferedReader(new FileReader(file))
def line, hasSPDX = false, hasTraditional = false
while ((line = r.readLine()) != null) {
if (line.contains("SPDX-License-Identifier")) {
hasSPDX = true
break
}
if (line.contains("http://www.apache.org/licenses/LICENSE-2.0")) {
hasTraditional = true
break
}
}
if (!hasSPDX) {
if (hasTraditional) {
noSPDX.add(file)
} else {
missing.add(file)
}
}
}
}

if (noSPDX.isEmpty()) {
println "All remaining files have Apache 2.0 headers"
} else {
println "We are standardizing with the SPDX style license headers."
println "The following files contain the traditional license headers which are still valid:"
noSPDX.each {
f -> println "\t" + f.getPath()
}
println "If you need to make a content update, please replace the Apache license header comment text with:"
println "\tSPDX-License-Identifier: Apache-2.0\n"
}

if (!missing.isEmpty()) {
def error = "The following files are missing Apache 2.0 headers:\n"
missing.each {
f -> error += f.getPath() + "\n"
}
error += "Fatal Error - All files must have a license header"
throw new IllegalArgumentException(error)
}
}

build.dependsOn licenseCheck
7 changes: 6 additions & 1 deletion shim/src/main/java/commons-logging.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# commons-logging.properties
#
# Copyright IBM Corp. All Rights Reserved.
#
# SPDX-License-Identifier: Apache-2.0
#

# jdk handlers
handlers=java.util.logging.FileHandler, java.util.logging.ConsoleHandler

Expand Down
23 changes: 8 additions & 15 deletions shim/src/main/java/org/hyperledger/fabric/shim/Chaincode.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
// Copyright IBM 2017 All Rights Reserved.
//
// 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 org.hyperledger.fabric.shim;
/*
Copyright IBM Corp. All Rights Reserved.
import static java.nio.charset.StandardCharsets.UTF_8;
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim;

import java.util.HashMap;
import java.util.Map;

import static java.nio.charset.StandardCharsets.UTF_8;

/**
* Defines methods that all chaincodes must implement.
*/
Expand Down
47 changes: 17 additions & 30 deletions shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeBase.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,19 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim;

import static org.hyperledger.fabric.shim.Chaincode.Response.Status.INTERNAL_SERVER_ERROR;
import static org.hyperledger.fabric.shim.Chaincode.Response.Status.SUCCESS;

import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;

import javax.net.ssl.SSLException;

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import io.grpc.ManagedChannel;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.handler.ssl.SslContext;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Options;
Expand All @@ -39,15 +27,14 @@
import org.hyperledger.fabric.shim.impl.Handler;
import org.hyperledger.fabric.shim.impl.NextStateInfo;

import com.google.protobuf.InvalidProtocolBufferException;
import com.google.protobuf.util.JsonFormat;
import javax.net.ssl.SSLException;
import java.io.File;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;

import io.grpc.ManagedChannel;
import io.grpc.netty.GrpcSslContexts;
import io.grpc.netty.NegotiationType;
import io.grpc.netty.NettyChannelBuilder;
import io.grpc.stub.StreamObserver;
import io.netty.handler.ssl.SslContext;
import static org.hyperledger.fabric.shim.Chaincode.Response.Status.INTERNAL_SERVER_ERROR;
import static org.hyperledger.fabric.shim.Chaincode.Response.Status.SUCCESS;

public abstract class ChaincodeBase implements Chaincode {

Expand Down
27 changes: 9 additions & 18 deletions shim/src/main/java/org/hyperledger/fabric/shim/ChaincodeStub.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
/*
Copyright IBM 2017 All Rights Reserved.
Copyright IBM Corp. All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.fabric.shim;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;

import java.util.Arrays;
import java.util.List;
package org.hyperledger.fabric.shim;

import org.hyperledger.fabric.protos.peer.ChaincodeEventPackage.ChaincodeEvent;
import org.hyperledger.fabric.protos.peer.ProposalPackage.SignedProposal;
Expand All @@ -29,6 +14,12 @@
import org.hyperledger.fabric.shim.ledger.KeyValue;
import org.hyperledger.fabric.shim.ledger.QueryResultsIterator;

import java.util.Arrays;
import java.util.List;

import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.stream.Collectors.toList;

public interface ChaincodeStub {

/**
Expand Down
14 changes: 2 additions & 12 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/CBDesc.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
14 changes: 2 additions & 12 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/Callback.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
14 changes: 2 additions & 12 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/Event.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
14 changes: 2 additions & 12 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/EventDesc.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
14 changes: 2 additions & 12 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/EventKey.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;
Expand Down
24 changes: 4 additions & 20 deletions shim/src/main/java/org/hyperledger/fabric/shim/fsm/FSM.java
Original file line number Diff line number Diff line change
@@ -1,32 +1,16 @@
/*
Copyright DTCC 2016 All Rights Reserved.
Copyright IBM Corp., DTCC All Rights Reserved.
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.
SPDX-License-Identifier: Apache-2.0
*/

package org.hyperledger.fabric.shim.fsm;

import org.hyperledger.fabric.shim.fsm.exceptions.*;

import java.util.HashMap;
import java.util.HashSet;

import org.hyperledger.fabric.shim.fsm.exceptions.AsyncException;
import org.hyperledger.fabric.shim.fsm.exceptions.CancelledException;
import org.hyperledger.fabric.shim.fsm.exceptions.InTrasistionException;
import org.hyperledger.fabric.shim.fsm.exceptions.InvalidEventException;
import org.hyperledger.fabric.shim.fsm.exceptions.NoTransitionException;
import org.hyperledger.fabric.shim.fsm.exceptions.NotInTransitionException;
import org.hyperledger.fabric.shim.fsm.exceptions.UnknownEventException;

public class FSM {

/** The current state of the FSM */
Expand Down
Loading

0 comments on commit 64de43a

Please sign in to comment.