id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
22,100
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java
|
Utils.checkGrpcUrl
|
public static Exception checkGrpcUrl(String url) {
try {
parseGrpcUrl(url);
return null;
} catch (Exception e) {
return e;
}
}
|
java
|
public static Exception checkGrpcUrl(String url) {
try {
parseGrpcUrl(url);
return null;
} catch (Exception e) {
return e;
}
}
|
[
"public",
"static",
"Exception",
"checkGrpcUrl",
"(",
"String",
"url",
")",
"{",
"try",
"{",
"parseGrpcUrl",
"(",
"url",
")",
";",
"return",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"e",
";",
"}",
"}"
] |
Check if the strings Grpc url is valid
@param url
@return Return the exception that indicates the error or null if ok.
|
[
"Check",
"if",
"the",
"strings",
"Grpc",
"url",
"is",
"valid"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java#L346-L355
|
22,101
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java
|
Utils.logString
|
public static String logString(final String string) {
if (string == null || string.length() == 0) {
return string;
}
String ret = string.replaceAll("[^\\p{Print}]", "?");
ret = ret.substring(0, Math.min(ret.length(), MAX_LOG_STRING_LENGTH)) + (ret.length() > MAX_LOG_STRING_LENGTH ? "..." : "");
return ret;
}
|
java
|
public static String logString(final String string) {
if (string == null || string.length() == 0) {
return string;
}
String ret = string.replaceAll("[^\\p{Print}]", "?");
ret = ret.substring(0, Math.min(ret.length(), MAX_LOG_STRING_LENGTH)) + (ret.length() > MAX_LOG_STRING_LENGTH ? "..." : "");
return ret;
}
|
[
"public",
"static",
"String",
"logString",
"(",
"final",
"String",
"string",
")",
"{",
"if",
"(",
"string",
"==",
"null",
"||",
"string",
".",
"length",
"(",
")",
"==",
"0",
")",
"{",
"return",
"string",
";",
"}",
"String",
"ret",
"=",
"string",
".",
"replaceAll",
"(",
"\"[^\\\\p{Print}]\"",
",",
"\"?\"",
")",
";",
"ret",
"=",
"ret",
".",
"substring",
"(",
"0",
",",
"Math",
".",
"min",
"(",
"ret",
".",
"length",
"(",
")",
",",
"MAX_LOG_STRING_LENGTH",
")",
")",
"+",
"(",
"ret",
".",
"length",
"(",
")",
">",
"MAX_LOG_STRING_LENGTH",
"?",
"\"...\"",
":",
"\"\"",
")",
";",
"return",
"ret",
";",
"}"
] |
Makes logging strings which can be long or with unprintable characters be logged and trimmed.
@param string Unsafe string too long
@return returns a string which does not have unprintable characters and trimmed in length.
|
[
"Makes",
"logging",
"strings",
"which",
"can",
"be",
"long",
"or",
"with",
"unprintable",
"characters",
"be",
"logged",
"and",
"trimmed",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Utils.java#L373-L384
|
22,102
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/helper/Config.java
|
Config.getSecurityCurveMapping
|
public Map<Integer, String> getSecurityCurveMapping() {
if (curveMapping == null) {
curveMapping = parseSecurityCurveMappings(getProperty(SECURITY_CURVE_MAPPING));
}
return Collections.unmodifiableMap(curveMapping);
}
|
java
|
public Map<Integer, String> getSecurityCurveMapping() {
if (curveMapping == null) {
curveMapping = parseSecurityCurveMappings(getProperty(SECURITY_CURVE_MAPPING));
}
return Collections.unmodifiableMap(curveMapping);
}
|
[
"public",
"Map",
"<",
"Integer",
",",
"String",
">",
"getSecurityCurveMapping",
"(",
")",
"{",
"if",
"(",
"curveMapping",
"==",
"null",
")",
"{",
"curveMapping",
"=",
"parseSecurityCurveMappings",
"(",
"getProperty",
"(",
"SECURITY_CURVE_MAPPING",
")",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableMap",
"(",
"curveMapping",
")",
";",
"}"
] |
Get a mapping from strength to curve desired.
@return mapping from strength to curve name to use.
|
[
"Get",
"a",
"mapping",
"from",
"strength",
"to",
"curve",
"desired",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Config.java#L359-L367
|
22,103
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/helper/Config.java
|
Config.getDiagnosticFileDumper
|
public DiagnosticFileDumper getDiagnosticFileDumper() {
if (diagnosticFileDumper != null) {
return diagnosticFileDumper;
}
String dd = sdkProperties.getProperty(DIAGNOTISTIC_FILE_DIRECTORY);
if (dd != null) {
diagnosticFileDumper = DiagnosticFileDumper.configInstance(new File(dd));
}
return diagnosticFileDumper;
}
|
java
|
public DiagnosticFileDumper getDiagnosticFileDumper() {
if (diagnosticFileDumper != null) {
return diagnosticFileDumper;
}
String dd = sdkProperties.getProperty(DIAGNOTISTIC_FILE_DIRECTORY);
if (dd != null) {
diagnosticFileDumper = DiagnosticFileDumper.configInstance(new File(dd));
}
return diagnosticFileDumper;
}
|
[
"public",
"DiagnosticFileDumper",
"getDiagnosticFileDumper",
"(",
")",
"{",
"if",
"(",
"diagnosticFileDumper",
"!=",
"null",
")",
"{",
"return",
"diagnosticFileDumper",
";",
"}",
"String",
"dd",
"=",
"sdkProperties",
".",
"getProperty",
"(",
"DIAGNOTISTIC_FILE_DIRECTORY",
")",
";",
"if",
"(",
"dd",
"!=",
"null",
")",
"{",
"diagnosticFileDumper",
"=",
"DiagnosticFileDumper",
".",
"configInstance",
"(",
"new",
"File",
"(",
"dd",
")",
")",
";",
"}",
"return",
"diagnosticFileDumper",
";",
"}"
] |
The directory where diagnostic dumps are to be place, null if none should be done.
@return The directory where diagnostic dumps are to be place, null if none should be done.
|
[
"The",
"directory",
"where",
"diagnostic",
"dumps",
"are",
"to",
"be",
"place",
"null",
"if",
"none",
"should",
"be",
"done",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Config.java#L528-L543
|
22,104
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/helper/Config.java
|
Config.getLifecycleInitRequiredDefault
|
public Boolean getLifecycleInitRequiredDefault() {
String property = getProperty(LIFECYCLE_INITREQUIREDDEFAULT);
if (property != null) {
return Boolean.parseBoolean(property);
}
return null;
}
|
java
|
public Boolean getLifecycleInitRequiredDefault() {
String property = getProperty(LIFECYCLE_INITREQUIREDDEFAULT);
if (property != null) {
return Boolean.parseBoolean(property);
}
return null;
}
|
[
"public",
"Boolean",
"getLifecycleInitRequiredDefault",
"(",
")",
"{",
"String",
"property",
"=",
"getProperty",
"(",
"LIFECYCLE_INITREQUIREDDEFAULT",
")",
";",
"if",
"(",
"property",
"!=",
"null",
")",
"{",
"return",
"Boolean",
".",
"parseBoolean",
"(",
"property",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Whether require init method in chaincode to be run.
The default will return null which will not set the Fabric protobuf value which then sets false. False is the Fabric
default.
@return The default setting for initRequired in chaincode approve for my org and commit chaincode definition.
|
[
"Whether",
"require",
"init",
"method",
"in",
"chaincode",
"to",
"be",
"run",
".",
"The",
"default",
"will",
"return",
"null",
"which",
"will",
"not",
"set",
"the",
"Fabric",
"protobuf",
"value",
"which",
"then",
"sets",
"false",
".",
"False",
"is",
"the",
"Fabric",
"default",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/helper/Config.java#L626-L636
|
22,105
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/InstallProposalRequest.java
|
InstallProposalRequest.setChaincodeInputStream
|
public void setChaincodeInputStream(InputStream chaincodeInputStream) throws InvalidArgumentException {
if (chaincodeInputStream == null) {
throw new InvalidArgumentException("Chaincode input stream may not be null.");
}
if (chaincodeSourceLocation != null) {
throw new InvalidArgumentException("Error setting chaincode input stream. Chaincode source location already set. Only one or the other maybe set.");
}
if (chaincodeMetaInfLocation != null) {
throw new InvalidArgumentException("Error setting chaincode input stream. Chaincode META-INF location already set. Only one or the other maybe set.");
}
this.chaincodeInputStream = chaincodeInputStream;
}
|
java
|
public void setChaincodeInputStream(InputStream chaincodeInputStream) throws InvalidArgumentException {
if (chaincodeInputStream == null) {
throw new InvalidArgumentException("Chaincode input stream may not be null.");
}
if (chaincodeSourceLocation != null) {
throw new InvalidArgumentException("Error setting chaincode input stream. Chaincode source location already set. Only one or the other maybe set.");
}
if (chaincodeMetaInfLocation != null) {
throw new InvalidArgumentException("Error setting chaincode input stream. Chaincode META-INF location already set. Only one or the other maybe set.");
}
this.chaincodeInputStream = chaincodeInputStream;
}
|
[
"public",
"void",
"setChaincodeInputStream",
"(",
"InputStream",
"chaincodeInputStream",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"chaincodeInputStream",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Chaincode input stream may not be null.\"",
")",
";",
"}",
"if",
"(",
"chaincodeSourceLocation",
"!=",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Error setting chaincode input stream. Chaincode source location already set. Only one or the other maybe set.\"",
")",
";",
"}",
"if",
"(",
"chaincodeMetaInfLocation",
"!=",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Error setting chaincode input stream. Chaincode META-INF location already set. Only one or the other maybe set.\"",
")",
";",
"}",
"this",
".",
"chaincodeInputStream",
"=",
"chaincodeInputStream",
";",
"}"
] |
Chaincode input stream containing the actual chaincode. Only format supported is a tar zip compressed input of the source.
Only input stream or source location maybe used at the same time.
The contents of the stream are not validated or inspected by the SDK.
@param chaincodeInputStream
@throws InvalidArgumentException
|
[
"Chaincode",
"input",
"stream",
"containing",
"the",
"actual",
"chaincode",
".",
"Only",
"format",
"supported",
"is",
"a",
"tar",
"zip",
"compressed",
"input",
"of",
"the",
"source",
".",
"Only",
"input",
"stream",
"or",
"source",
"location",
"maybe",
"used",
"at",
"the",
"same",
"time",
".",
"The",
"contents",
"of",
"the",
"stream",
"are",
"not",
"validated",
"or",
"inspected",
"by",
"the",
"SDK",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/InstallProposalRequest.java#L66-L77
|
22,106
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/InstallProposalRequest.java
|
InstallProposalRequest.setChaincodeSourceLocation
|
public void setChaincodeSourceLocation(File chaincodeSourceLocation) throws InvalidArgumentException {
if (chaincodeSourceLocation == null) {
throw new InvalidArgumentException("Chaincode source location may not be null.");
}
if (chaincodeInputStream != null) {
throw new InvalidArgumentException("Error setting chaincode location. Chaincode input stream already set. Only one or the other maybe set.");
}
this.chaincodeSourceLocation = chaincodeSourceLocation;
}
|
java
|
public void setChaincodeSourceLocation(File chaincodeSourceLocation) throws InvalidArgumentException {
if (chaincodeSourceLocation == null) {
throw new InvalidArgumentException("Chaincode source location may not be null.");
}
if (chaincodeInputStream != null) {
throw new InvalidArgumentException("Error setting chaincode location. Chaincode input stream already set. Only one or the other maybe set.");
}
this.chaincodeSourceLocation = chaincodeSourceLocation;
}
|
[
"public",
"void",
"setChaincodeSourceLocation",
"(",
"File",
"chaincodeSourceLocation",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"chaincodeSourceLocation",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Chaincode source location may not be null.\"",
")",
";",
"}",
"if",
"(",
"chaincodeInputStream",
"!=",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Error setting chaincode location. Chaincode input stream already set. Only one or the other maybe set.\"",
")",
";",
"}",
"this",
".",
"chaincodeSourceLocation",
"=",
"chaincodeSourceLocation",
";",
"}"
] |
The location of the chaincode.
Chaincode input stream and source location can not both be set.
@param chaincodeSourceLocation
@throws InvalidArgumentException
|
[
"The",
"location",
"of",
"the",
"chaincode",
".",
"Chaincode",
"input",
"stream",
"and",
"source",
"location",
"can",
"not",
"both",
"be",
"set",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/InstallProposalRequest.java#L90-L99
|
22,107
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/LifecycleQueryApprovalStatusRequest.java
|
LifecycleQueryApprovalStatusRequest.setChaincodeCollectionConfiguration
|
public void setChaincodeCollectionConfiguration(ChaincodeCollectionConfiguration collectionConfigPackage) throws InvalidArgumentException {
if (null == collectionConfigPackage) {
throw new InvalidArgumentException("The parameter collectionConfigPackage may not be null.");
}
this.collectionConfigPackage = collectionConfigPackage.getCollectionConfigPackage();
}
|
java
|
public void setChaincodeCollectionConfiguration(ChaincodeCollectionConfiguration collectionConfigPackage) throws InvalidArgumentException {
if (null == collectionConfigPackage) {
throw new InvalidArgumentException("The parameter collectionConfigPackage may not be null.");
}
this.collectionConfigPackage = collectionConfigPackage.getCollectionConfigPackage();
}
|
[
"public",
"void",
"setChaincodeCollectionConfiguration",
"(",
"ChaincodeCollectionConfiguration",
"collectionConfigPackage",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"null",
"==",
"collectionConfigPackage",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The parameter collectionConfigPackage may not be null.\"",
")",
";",
"}",
"this",
".",
"collectionConfigPackage",
"=",
"collectionConfigPackage",
".",
"getCollectionConfigPackage",
"(",
")",
";",
"}"
] |
The collection configuration for the approval being queried for.
@param collectionConfigPackage
@throws InvalidArgumentException
|
[
"The",
"collection",
"configuration",
"for",
"the",
"approval",
"being",
"queried",
"for",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/LifecycleQueryApprovalStatusRequest.java#L199-L205
|
22,108
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.addPeer
|
public Channel addPeer(Peer peer, PeerOptions peerOptions) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == peer) {
throw new InvalidArgumentException("Peer is invalid can not be null.");
}
if (peer.getChannel() != null && peer.getChannel() != this) {
throw new InvalidArgumentException(format("Peer already connected to channel %s", peer.getChannel().getName()));
}
if (null == peerOptions) {
throw new InvalidArgumentException("peerOptions is invalid can not be null.");
}
logger.debug(format("%s adding peer: %s, peerOptions: %s", toString(), peer, "" + peerOptions));
peer.setChannel(this);
peers.add(peer);
peerOptionsMap.put(peer, peerOptions.clone());
peerEndpointMap.put(peer.getEndpoint(), peer);
if (peerOptions.getPeerRoles().contains(PeerRole.SERVICE_DISCOVERY)) {
final Properties properties = peer.getProperties();
if ((properties == null) || properties.isEmpty() || (isNullOrEmpty(properties.getProperty("clientCertFile")) &&
!properties.containsKey("clientCertBytes"))) {
TLSCertificateBuilder tlsCertificateBuilder = new TLSCertificateBuilder();
TLSCertificateKeyPair tlsCertificateKeyPair = tlsCertificateBuilder.clientCert();
peer.setTLSCertificateKeyPair(tlsCertificateKeyPair);
}
discoveryEndpoints.add(peer.getEndpoint());
}
for (Map.Entry<PeerRole, Set<Peer>> peerRole : peerRoleSetMap.entrySet()) {
if (peerOptions.getPeerRoles().contains(peerRole.getKey())) {
peerRole.getValue().add(peer);
}
}
if (isInitialized() && peerOptions.getPeerRoles().contains(PeerRole.EVENT_SOURCE)) {
try {
peer.initiateEventing(getTransactionContext(), getPeersOptions(peer));
} catch (TransactionException e) {
logger.error(format("Error channel %s enabling eventing on peer %s", toString(), peer));
}
}
return this;
}
|
java
|
public Channel addPeer(Peer peer, PeerOptions peerOptions) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == peer) {
throw new InvalidArgumentException("Peer is invalid can not be null.");
}
if (peer.getChannel() != null && peer.getChannel() != this) {
throw new InvalidArgumentException(format("Peer already connected to channel %s", peer.getChannel().getName()));
}
if (null == peerOptions) {
throw new InvalidArgumentException("peerOptions is invalid can not be null.");
}
logger.debug(format("%s adding peer: %s, peerOptions: %s", toString(), peer, "" + peerOptions));
peer.setChannel(this);
peers.add(peer);
peerOptionsMap.put(peer, peerOptions.clone());
peerEndpointMap.put(peer.getEndpoint(), peer);
if (peerOptions.getPeerRoles().contains(PeerRole.SERVICE_DISCOVERY)) {
final Properties properties = peer.getProperties();
if ((properties == null) || properties.isEmpty() || (isNullOrEmpty(properties.getProperty("clientCertFile")) &&
!properties.containsKey("clientCertBytes"))) {
TLSCertificateBuilder tlsCertificateBuilder = new TLSCertificateBuilder();
TLSCertificateKeyPair tlsCertificateKeyPair = tlsCertificateBuilder.clientCert();
peer.setTLSCertificateKeyPair(tlsCertificateKeyPair);
}
discoveryEndpoints.add(peer.getEndpoint());
}
for (Map.Entry<PeerRole, Set<Peer>> peerRole : peerRoleSetMap.entrySet()) {
if (peerOptions.getPeerRoles().contains(peerRole.getKey())) {
peerRole.getValue().add(peer);
}
}
if (isInitialized() && peerOptions.getPeerRoles().contains(PeerRole.EVENT_SOURCE)) {
try {
peer.initiateEventing(getTransactionContext(), getPeersOptions(peer));
} catch (TransactionException e) {
logger.error(format("Error channel %s enabling eventing on peer %s", toString(), peer));
}
}
return this;
}
|
[
"public",
"Channel",
"addPeer",
"(",
"Peer",
"peer",
",",
"PeerOptions",
"peerOptions",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"peer",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Peer is invalid can not be null.\"",
")",
";",
"}",
"if",
"(",
"peer",
".",
"getChannel",
"(",
")",
"!=",
"null",
"&&",
"peer",
".",
"getChannel",
"(",
")",
"!=",
"this",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Peer already connected to channel %s\"",
",",
"peer",
".",
"getChannel",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"peerOptions",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"peerOptions is invalid can not be null.\"",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"%s adding peer: %s, peerOptions: %s\"",
",",
"toString",
"(",
")",
",",
"peer",
",",
"\"\"",
"+",
"peerOptions",
")",
")",
";",
"peer",
".",
"setChannel",
"(",
"this",
")",
";",
"peers",
".",
"add",
"(",
"peer",
")",
";",
"peerOptionsMap",
".",
"put",
"(",
"peer",
",",
"peerOptions",
".",
"clone",
"(",
")",
")",
";",
"peerEndpointMap",
".",
"put",
"(",
"peer",
".",
"getEndpoint",
"(",
")",
",",
"peer",
")",
";",
"if",
"(",
"peerOptions",
".",
"getPeerRoles",
"(",
")",
".",
"contains",
"(",
"PeerRole",
".",
"SERVICE_DISCOVERY",
")",
")",
"{",
"final",
"Properties",
"properties",
"=",
"peer",
".",
"getProperties",
"(",
")",
";",
"if",
"(",
"(",
"properties",
"==",
"null",
")",
"||",
"properties",
".",
"isEmpty",
"(",
")",
"||",
"(",
"isNullOrEmpty",
"(",
"properties",
".",
"getProperty",
"(",
"\"clientCertFile\"",
")",
")",
"&&",
"!",
"properties",
".",
"containsKey",
"(",
"\"clientCertBytes\"",
")",
")",
")",
"{",
"TLSCertificateBuilder",
"tlsCertificateBuilder",
"=",
"new",
"TLSCertificateBuilder",
"(",
")",
";",
"TLSCertificateKeyPair",
"tlsCertificateKeyPair",
"=",
"tlsCertificateBuilder",
".",
"clientCert",
"(",
")",
";",
"peer",
".",
"setTLSCertificateKeyPair",
"(",
"tlsCertificateKeyPair",
")",
";",
"}",
"discoveryEndpoints",
".",
"add",
"(",
"peer",
".",
"getEndpoint",
"(",
")",
")",
";",
"}",
"for",
"(",
"Map",
".",
"Entry",
"<",
"PeerRole",
",",
"Set",
"<",
"Peer",
">",
">",
"peerRole",
":",
"peerRoleSetMap",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"peerOptions",
".",
"getPeerRoles",
"(",
")",
".",
"contains",
"(",
"peerRole",
".",
"getKey",
"(",
")",
")",
")",
"{",
"peerRole",
".",
"getValue",
"(",
")",
".",
"add",
"(",
"peer",
")",
";",
"}",
"}",
"if",
"(",
"isInitialized",
"(",
")",
"&&",
"peerOptions",
".",
"getPeerRoles",
"(",
")",
".",
"contains",
"(",
"PeerRole",
".",
"EVENT_SOURCE",
")",
")",
"{",
"try",
"{",
"peer",
".",
"initiateEventing",
"(",
"getTransactionContext",
"(",
")",
",",
"getPeersOptions",
"(",
"peer",
")",
")",
";",
"}",
"catch",
"(",
"TransactionException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"format",
"(",
"\"Error channel %s enabling eventing on peer %s\"",
",",
"toString",
"(",
")",
",",
"peer",
")",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] |
Add a peer to the channel
@param peer The Peer to add.
@param peerOptions see {@link PeerRole}
@return Channel The current channel added.
@throws InvalidArgumentException
|
[
"Add",
"a",
"peer",
"to",
"the",
"channel"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L626-L680
|
22,109
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.addOrderer
|
public Channel addOrderer(Orderer orderer) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == orderer) {
throw new InvalidArgumentException("Orderer is invalid can not be null.");
}
logger.debug(format("Channel %s adding %s", toString(), orderer.toString()));
orderer.setChannel(this);
ordererEndpointMap.put(orderer.getEndpoint(), orderer);
orderers.add(orderer);
return this;
}
|
java
|
public Channel addOrderer(Orderer orderer) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == orderer) {
throw new InvalidArgumentException("Orderer is invalid can not be null.");
}
logger.debug(format("Channel %s adding %s", toString(), orderer.toString()));
orderer.setChannel(this);
ordererEndpointMap.put(orderer.getEndpoint(), orderer);
orderers.add(orderer);
return this;
}
|
[
"public",
"Channel",
"addOrderer",
"(",
"Orderer",
"orderer",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"orderer",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Orderer is invalid can not be null.\"",
")",
";",
"}",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s adding %s\"",
",",
"toString",
"(",
")",
",",
"orderer",
".",
"toString",
"(",
")",
")",
")",
";",
"orderer",
".",
"setChannel",
"(",
"this",
")",
";",
"ordererEndpointMap",
".",
"put",
"(",
"orderer",
".",
"getEndpoint",
"(",
")",
",",
"orderer",
")",
";",
"orderers",
".",
"add",
"(",
"orderer",
")",
";",
"return",
"this",
";",
"}"
] |
Add an Orderer to this channel.
@param orderer the orderer to add.
@return this channel.
@throws InvalidArgumentException
|
[
"Add",
"an",
"Orderer",
"to",
"this",
"channel",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L923-L939
|
22,110
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.getPeers
|
public Collection<Peer> getPeers(EnumSet<PeerRole> roles) {
Set<Peer> ret = new HashSet<>(getPeers().size());
for (PeerRole peerRole : roles) {
ret.addAll(peerRoleSetMap.get(peerRole));
}
return Collections.unmodifiableCollection(ret);
}
|
java
|
public Collection<Peer> getPeers(EnumSet<PeerRole> roles) {
Set<Peer> ret = new HashSet<>(getPeers().size());
for (PeerRole peerRole : roles) {
ret.addAll(peerRoleSetMap.get(peerRole));
}
return Collections.unmodifiableCollection(ret);
}
|
[
"public",
"Collection",
"<",
"Peer",
">",
"getPeers",
"(",
"EnumSet",
"<",
"PeerRole",
">",
"roles",
")",
"{",
"Set",
"<",
"Peer",
">",
"ret",
"=",
"new",
"HashSet",
"<>",
"(",
"getPeers",
"(",
")",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"PeerRole",
"peerRole",
":",
"roles",
")",
"{",
"ret",
".",
"addAll",
"(",
"peerRoleSetMap",
".",
"get",
"(",
"peerRole",
")",
")",
";",
"}",
"return",
"Collections",
".",
"unmodifiableCollection",
"(",
"ret",
")",
";",
"}"
] |
Get the peers for this channel.
@return the peers.
|
[
"Get",
"the",
"peers",
"for",
"this",
"channel",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L982-L991
|
22,111
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.setPeerOptions
|
PeerOptions setPeerOptions(Peer peer, PeerOptions peerOptions) throws InvalidArgumentException {
if (initialized) {
throw new InvalidArgumentException(format("Channel %s already initialized.", name));
}
checkPeer(peer);
PeerOptions ret = getPeersOptions(peer);
removePeerInternal(peer);
addPeer(peer, peerOptions);
return ret;
}
|
java
|
PeerOptions setPeerOptions(Peer peer, PeerOptions peerOptions) throws InvalidArgumentException {
if (initialized) {
throw new InvalidArgumentException(format("Channel %s already initialized.", name));
}
checkPeer(peer);
PeerOptions ret = getPeersOptions(peer);
removePeerInternal(peer);
addPeer(peer, peerOptions);
return ret;
}
|
[
"PeerOptions",
"setPeerOptions",
"(",
"Peer",
"peer",
",",
"PeerOptions",
"peerOptions",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"initialized",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s already initialized.\"",
",",
"name",
")",
")",
";",
"}",
"checkPeer",
"(",
"peer",
")",
";",
"PeerOptions",
"ret",
"=",
"getPeersOptions",
"(",
"peer",
")",
";",
"removePeerInternal",
"(",
"peer",
")",
";",
"addPeer",
"(",
"peer",
",",
"peerOptions",
")",
";",
"return",
"ret",
";",
"}"
] |
Set peerOptions in the channel that has not be initialized yet.
@param peer the peer to set options on.
@param peerOptions see {@link PeerOptions}
@return old options.
|
[
"Set",
"peerOptions",
"in",
"the",
"channel",
"that",
"has",
"not",
"be",
"initialized",
"yet",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L1001-L1013
|
22,112
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.initialize
|
public Channel initialize() throws InvalidArgumentException, TransactionException {
logger.debug(format("Channel %s initialize shutdown %b", name, shutdown));
if (isInitialized()) {
return this;
}
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (isNullOrEmpty(name)) {
throw new InvalidArgumentException("Can not initialize channel without a valid name.");
}
if (client == null) {
throw new InvalidArgumentException("Can not initialize channel without a client object.");
}
userContextCheck(client.getUserContext());
if (null == sdOrdererAddition) {
setSDOrdererAddition(new SDOrdererDefaultAddition(getServiceDiscoveryProperties()));
}
if (null == sdPeerAddition) {
setSDPeerAddition(new SDOPeerDefaultAddition(getServiceDiscoveryProperties()));
}
try {
loadCACertificates(false); // put all MSP certs into cryptoSuite if this fails here we'll try again later.
} catch (Exception e) {
logger.warn(format("Channel %s could not load peer CA certificates from any peers.", name));
}
Collection<Peer> serviceDiscoveryPeers = getServiceDiscoveryPeers();
if (!serviceDiscoveryPeers.isEmpty()) {
logger.trace("Starting service discovery.");
this.serviceDiscovery = new ServiceDiscovery(this, serviceDiscoveryPeers, getTransactionContext());
serviceDiscovery.fullNetworkDiscovery(true);
serviceDiscovery.run();
logger.trace("Completed. service discovery.");
}
try {
logger.debug(format("Eventque started %s", "" + eventQueueThread));
for (Peer peer : getEventingPeers()) {
peer.initiateEventing(getTransactionContext(), getPeersOptions(peer));
}
transactionListenerProcessorHandle = registerTransactionListenerProcessor(); //Manage transactions.
logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name));
if (serviceDiscovery != null) {
chaincodeEventUpgradeListenerHandle = registerChaincodeEventListener(Pattern.compile("^lscc$"), Pattern.compile("^upgrade$"), (handle, blockEvent, chaincodeEvent) -> {
logger.debug(format("Channel %s got upgrade chaincode event", name));
if (!isShutdown() && isChaincodeUpgradeEvent(blockEvent.getBlockNumber())) {
getExecutorService().execute(() -> serviceDiscovery.fullNetworkDiscovery(true));
}
});
}
startEventQue(); //Run the event for event messages from event hubs.
logger.info(format("Channel %s eventThread started shutdown: %b thread: %s ", toString(), shutdown, eventQueueThread == null ? "null" : eventQueueThread.getName()));
this.initialized = true;
logger.debug(format("Channel %s initialized", name));
return this;
} catch (Exception e) {
TransactionException exp = new TransactionException(e);
logger.error(exp.getMessage(), exp);
throw exp;
}
}
|
java
|
public Channel initialize() throws InvalidArgumentException, TransactionException {
logger.debug(format("Channel %s initialize shutdown %b", name, shutdown));
if (isInitialized()) {
return this;
}
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (isNullOrEmpty(name)) {
throw new InvalidArgumentException("Can not initialize channel without a valid name.");
}
if (client == null) {
throw new InvalidArgumentException("Can not initialize channel without a client object.");
}
userContextCheck(client.getUserContext());
if (null == sdOrdererAddition) {
setSDOrdererAddition(new SDOrdererDefaultAddition(getServiceDiscoveryProperties()));
}
if (null == sdPeerAddition) {
setSDPeerAddition(new SDOPeerDefaultAddition(getServiceDiscoveryProperties()));
}
try {
loadCACertificates(false); // put all MSP certs into cryptoSuite if this fails here we'll try again later.
} catch (Exception e) {
logger.warn(format("Channel %s could not load peer CA certificates from any peers.", name));
}
Collection<Peer> serviceDiscoveryPeers = getServiceDiscoveryPeers();
if (!serviceDiscoveryPeers.isEmpty()) {
logger.trace("Starting service discovery.");
this.serviceDiscovery = new ServiceDiscovery(this, serviceDiscoveryPeers, getTransactionContext());
serviceDiscovery.fullNetworkDiscovery(true);
serviceDiscovery.run();
logger.trace("Completed. service discovery.");
}
try {
logger.debug(format("Eventque started %s", "" + eventQueueThread));
for (Peer peer : getEventingPeers()) {
peer.initiateEventing(getTransactionContext(), getPeersOptions(peer));
}
transactionListenerProcessorHandle = registerTransactionListenerProcessor(); //Manage transactions.
logger.debug(format("Channel %s registerTransactionListenerProcessor completed", name));
if (serviceDiscovery != null) {
chaincodeEventUpgradeListenerHandle = registerChaincodeEventListener(Pattern.compile("^lscc$"), Pattern.compile("^upgrade$"), (handle, blockEvent, chaincodeEvent) -> {
logger.debug(format("Channel %s got upgrade chaincode event", name));
if (!isShutdown() && isChaincodeUpgradeEvent(blockEvent.getBlockNumber())) {
getExecutorService().execute(() -> serviceDiscovery.fullNetworkDiscovery(true));
}
});
}
startEventQue(); //Run the event for event messages from event hubs.
logger.info(format("Channel %s eventThread started shutdown: %b thread: %s ", toString(), shutdown, eventQueueThread == null ? "null" : eventQueueThread.getName()));
this.initialized = true;
logger.debug(format("Channel %s initialized", name));
return this;
} catch (Exception e) {
TransactionException exp = new TransactionException(e);
logger.error(exp.getMessage(), exp);
throw exp;
}
}
|
[
"public",
"Channel",
"initialize",
"(",
")",
"throws",
"InvalidArgumentException",
",",
"TransactionException",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s initialize shutdown %b\"",
",",
"name",
",",
"shutdown",
")",
")",
";",
"if",
"(",
"isInitialized",
"(",
")",
")",
"{",
"return",
"this",
";",
"}",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"isNullOrEmpty",
"(",
"name",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Can not initialize channel without a valid name.\"",
")",
";",
"}",
"if",
"(",
"client",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Can not initialize channel without a client object.\"",
")",
";",
"}",
"userContextCheck",
"(",
"client",
".",
"getUserContext",
"(",
")",
")",
";",
"if",
"(",
"null",
"==",
"sdOrdererAddition",
")",
"{",
"setSDOrdererAddition",
"(",
"new",
"SDOrdererDefaultAddition",
"(",
"getServiceDiscoveryProperties",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"sdPeerAddition",
")",
"{",
"setSDPeerAddition",
"(",
"new",
"SDOPeerDefaultAddition",
"(",
"getServiceDiscoveryProperties",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"loadCACertificates",
"(",
"false",
")",
";",
"// put all MSP certs into cryptoSuite if this fails here we'll try again later.",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"format",
"(",
"\"Channel %s could not load peer CA certificates from any peers.\"",
",",
"name",
")",
")",
";",
"}",
"Collection",
"<",
"Peer",
">",
"serviceDiscoveryPeers",
"=",
"getServiceDiscoveryPeers",
"(",
")",
";",
"if",
"(",
"!",
"serviceDiscoveryPeers",
".",
"isEmpty",
"(",
")",
")",
"{",
"logger",
".",
"trace",
"(",
"\"Starting service discovery.\"",
")",
";",
"this",
".",
"serviceDiscovery",
"=",
"new",
"ServiceDiscovery",
"(",
"this",
",",
"serviceDiscoveryPeers",
",",
"getTransactionContext",
"(",
")",
")",
";",
"serviceDiscovery",
".",
"fullNetworkDiscovery",
"(",
"true",
")",
";",
"serviceDiscovery",
".",
"run",
"(",
")",
";",
"logger",
".",
"trace",
"(",
"\"Completed. service discovery.\"",
")",
";",
"}",
"try",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Eventque started %s\"",
",",
"\"\"",
"+",
"eventQueueThread",
")",
")",
";",
"for",
"(",
"Peer",
"peer",
":",
"getEventingPeers",
"(",
")",
")",
"{",
"peer",
".",
"initiateEventing",
"(",
"getTransactionContext",
"(",
")",
",",
"getPeersOptions",
"(",
"peer",
")",
")",
";",
"}",
"transactionListenerProcessorHandle",
"=",
"registerTransactionListenerProcessor",
"(",
")",
";",
"//Manage transactions.",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s registerTransactionListenerProcessor completed\"",
",",
"name",
")",
")",
";",
"if",
"(",
"serviceDiscovery",
"!=",
"null",
")",
"{",
"chaincodeEventUpgradeListenerHandle",
"=",
"registerChaincodeEventListener",
"(",
"Pattern",
".",
"compile",
"(",
"\"^lscc$\"",
")",
",",
"Pattern",
".",
"compile",
"(",
"\"^upgrade$\"",
")",
",",
"(",
"handle",
",",
"blockEvent",
",",
"chaincodeEvent",
")",
"->",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s got upgrade chaincode event\"",
",",
"name",
")",
")",
";",
"if",
"(",
"!",
"isShutdown",
"(",
")",
"&&",
"isChaincodeUpgradeEvent",
"(",
"blockEvent",
".",
"getBlockNumber",
"(",
")",
")",
")",
"{",
"getExecutorService",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"serviceDiscovery",
".",
"fullNetworkDiscovery",
"(",
"true",
")",
")",
";",
"}",
"}",
")",
";",
"}",
"startEventQue",
"(",
")",
";",
"//Run the event for event messages from event hubs.",
"logger",
".",
"info",
"(",
"format",
"(",
"\"Channel %s eventThread started shutdown: %b thread: %s \"",
",",
"toString",
"(",
")",
",",
"shutdown",
",",
"eventQueueThread",
"==",
"null",
"?",
"\"null\"",
":",
"eventQueueThread",
".",
"getName",
"(",
")",
")",
")",
";",
"this",
".",
"initialized",
"=",
"true",
";",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s initialized\"",
",",
"name",
")",
")",
";",
"return",
"this",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"TransactionException",
"exp",
"=",
"new",
"TransactionException",
"(",
"e",
")",
";",
"logger",
".",
"error",
"(",
"exp",
".",
"getMessage",
"(",
")",
",",
"exp",
")",
";",
"throw",
"exp",
";",
"}",
"}"
] |
Initialize the Channel. Starts the channel. event hubs will connect.
@return this channel.
@throws InvalidArgumentException
@throws TransactionException
|
[
"Initialize",
"the",
"Channel",
".",
"Starts",
"the",
"channel",
".",
"event",
"hubs",
"will",
"connect",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L1034-L1119
|
22,113
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.loadCACertificates
|
protected synchronized void loadCACertificates(boolean force) throws InvalidArgumentException, CryptoException, TransactionException {
if (!force && msps != null && !msps.isEmpty()) {
return;
}
logger.debug(format("Channel %s loadCACertificates", name));
Map<String, MSP> lmsp = parseConfigBlock(force);
if (lmsp == null || lmsp.isEmpty()) {
throw new InvalidArgumentException("Unable to load CA certificates. Channel " + name + " does not have any MSPs.");
}
List<byte[]> certList;
for (MSP msp : lmsp.values()) {
logger.debug("loading certificates for MSP : " + msp.getID());
certList = Arrays.asList(msp.getRootCerts());
if (certList.size() > 0) {
client.getCryptoSuite().loadCACertificatesAsBytes(certList);
}
certList = Arrays.asList(msp.getIntermediateCerts());
if (certList.size() > 0) {
client.getCryptoSuite().loadCACertificatesAsBytes(certList);
}
// not adding admin certs. Admin certs should be signed by the CA
}
logger.debug(format("Channel %s loadCACertificates completed ", name));
}
|
java
|
protected synchronized void loadCACertificates(boolean force) throws InvalidArgumentException, CryptoException, TransactionException {
if (!force && msps != null && !msps.isEmpty()) {
return;
}
logger.debug(format("Channel %s loadCACertificates", name));
Map<String, MSP> lmsp = parseConfigBlock(force);
if (lmsp == null || lmsp.isEmpty()) {
throw new InvalidArgumentException("Unable to load CA certificates. Channel " + name + " does not have any MSPs.");
}
List<byte[]> certList;
for (MSP msp : lmsp.values()) {
logger.debug("loading certificates for MSP : " + msp.getID());
certList = Arrays.asList(msp.getRootCerts());
if (certList.size() > 0) {
client.getCryptoSuite().loadCACertificatesAsBytes(certList);
}
certList = Arrays.asList(msp.getIntermediateCerts());
if (certList.size() > 0) {
client.getCryptoSuite().loadCACertificatesAsBytes(certList);
}
// not adding admin certs. Admin certs should be signed by the CA
}
logger.debug(format("Channel %s loadCACertificates completed ", name));
}
|
[
"protected",
"synchronized",
"void",
"loadCACertificates",
"(",
"boolean",
"force",
")",
"throws",
"InvalidArgumentException",
",",
"CryptoException",
",",
"TransactionException",
"{",
"if",
"(",
"!",
"force",
"&&",
"msps",
"!=",
"null",
"&&",
"!",
"msps",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s loadCACertificates\"",
",",
"name",
")",
")",
";",
"Map",
"<",
"String",
",",
"MSP",
">",
"lmsp",
"=",
"parseConfigBlock",
"(",
"force",
")",
";",
"if",
"(",
"lmsp",
"==",
"null",
"||",
"lmsp",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unable to load CA certificates. Channel \"",
"+",
"name",
"+",
"\" does not have any MSPs.\"",
")",
";",
"}",
"List",
"<",
"byte",
"[",
"]",
">",
"certList",
";",
"for",
"(",
"MSP",
"msp",
":",
"lmsp",
".",
"values",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"\"loading certificates for MSP : \"",
"+",
"msp",
".",
"getID",
"(",
")",
")",
";",
"certList",
"=",
"Arrays",
".",
"asList",
"(",
"msp",
".",
"getRootCerts",
"(",
")",
")",
";",
"if",
"(",
"certList",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"client",
".",
"getCryptoSuite",
"(",
")",
".",
"loadCACertificatesAsBytes",
"(",
"certList",
")",
";",
"}",
"certList",
"=",
"Arrays",
".",
"asList",
"(",
"msp",
".",
"getIntermediateCerts",
"(",
")",
")",
";",
"if",
"(",
"certList",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"client",
".",
"getCryptoSuite",
"(",
")",
".",
"loadCACertificatesAsBytes",
"(",
"certList",
")",
";",
"}",
"// not adding admin certs. Admin certs should be signed by the CA",
"}",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s loadCACertificates completed \"",
",",
"name",
")",
")",
";",
"}"
] |
load the peer organizations CA certificates into the channel's trust store so that we
can verify signatures from peer messages
@throws InvalidArgumentException
@throws CryptoException
|
[
"load",
"the",
"peer",
"organizations",
"CA",
"certificates",
"into",
"the",
"channel",
"s",
"trust",
"store",
"so",
"that",
"we",
"can",
"verify",
"signatures",
"from",
"peer",
"messages"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L1562-L1589
|
22,114
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.getUpdateChannelConfigurationSignature
|
public byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer) throws InvalidArgumentException {
userContextCheck(signer);
if (null == updateChannelConfiguration) {
throw new InvalidArgumentException("channelConfiguration is null");
}
try {
TransactionContext transactionContext = getTransactionContext(signer);
final ByteString configUpdate = ByteString.copyFrom(updateChannelConfiguration.getUpdateChannelConfigurationAsBytes());
ByteString sigHeaderByteString = getSignatureHeaderAsByteString(signer, transactionContext);
ByteString signatureByteSting = transactionContext.signByteStrings(new User[] {signer},
sigHeaderByteString, configUpdate)[0];
return ConfigSignature.newBuilder()
.setSignatureHeader(sigHeaderByteString)
.setSignature(signatureByteSting)
.build().toByteArray();
} catch (Exception e) {
throw new InvalidArgumentException(e);
} finally {
logger.debug("finally done");
}
}
|
java
|
public byte[] getUpdateChannelConfigurationSignature(UpdateChannelConfiguration updateChannelConfiguration, User signer) throws InvalidArgumentException {
userContextCheck(signer);
if (null == updateChannelConfiguration) {
throw new InvalidArgumentException("channelConfiguration is null");
}
try {
TransactionContext transactionContext = getTransactionContext(signer);
final ByteString configUpdate = ByteString.copyFrom(updateChannelConfiguration.getUpdateChannelConfigurationAsBytes());
ByteString sigHeaderByteString = getSignatureHeaderAsByteString(signer, transactionContext);
ByteString signatureByteSting = transactionContext.signByteStrings(new User[] {signer},
sigHeaderByteString, configUpdate)[0];
return ConfigSignature.newBuilder()
.setSignatureHeader(sigHeaderByteString)
.setSignature(signatureByteSting)
.build().toByteArray();
} catch (Exception e) {
throw new InvalidArgumentException(e);
} finally {
logger.debug("finally done");
}
}
|
[
"public",
"byte",
"[",
"]",
"getUpdateChannelConfigurationSignature",
"(",
"UpdateChannelConfiguration",
"updateChannelConfiguration",
",",
"User",
"signer",
")",
"throws",
"InvalidArgumentException",
"{",
"userContextCheck",
"(",
"signer",
")",
";",
"if",
"(",
"null",
"==",
"updateChannelConfiguration",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"channelConfiguration is null\"",
")",
";",
"}",
"try",
"{",
"TransactionContext",
"transactionContext",
"=",
"getTransactionContext",
"(",
"signer",
")",
";",
"final",
"ByteString",
"configUpdate",
"=",
"ByteString",
".",
"copyFrom",
"(",
"updateChannelConfiguration",
".",
"getUpdateChannelConfigurationAsBytes",
"(",
")",
")",
";",
"ByteString",
"sigHeaderByteString",
"=",
"getSignatureHeaderAsByteString",
"(",
"signer",
",",
"transactionContext",
")",
";",
"ByteString",
"signatureByteSting",
"=",
"transactionContext",
".",
"signByteStrings",
"(",
"new",
"User",
"[",
"]",
"{",
"signer",
"}",
",",
"sigHeaderByteString",
",",
"configUpdate",
")",
"[",
"0",
"]",
";",
"return",
"ConfigSignature",
".",
"newBuilder",
"(",
")",
".",
"setSignatureHeader",
"(",
"sigHeaderByteString",
")",
".",
"setSignature",
"(",
"signatureByteSting",
")",
".",
"build",
"(",
")",
".",
"toByteArray",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"logger",
".",
"debug",
"(",
"\"finally done\"",
")",
";",
"}",
"}"
] |
Get signed byes of the update channel.
@param updateChannelConfiguration
@param signer
@return
@throws InvalidArgumentException
|
[
"Get",
"signed",
"byes",
"of",
"the",
"update",
"channel",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L1680-L1712
|
22,115
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.getConfigurationBlock
|
private Block getConfigurationBlock() throws TransactionException {
logger.debug(format("getConfigurationBlock for channel %s", name));
try {
Orderer orderer = getRandomOrderer();
long lastConfigIndex = getLastConfigIndex(orderer);
logger.debug(format("Last config index is %d", lastConfigIndex));
Block configBlock = getBlockByNumber(lastConfigIndex);
//Little extra parsing but make sure this really is a config block for this channel.
Envelope envelopeRet = Envelope.parseFrom(configBlock.getData().getData(0));
Payload payload = Payload.parseFrom(envelopeRet.getPayload());
ChannelHeader channelHeader = ChannelHeader.parseFrom(payload.getHeader().getChannelHeader());
if (channelHeader.getType() != HeaderType.CONFIG.getNumber()) {
throw new TransactionException(format("Bad last configuration block type %d, expected %d",
channelHeader.getType(), HeaderType.CONFIG.getNumber()));
}
if (!name.equals(channelHeader.getChannelId())) {
throw new TransactionException(format("Bad last configuration block channel id %s, expected %s",
channelHeader.getChannelId(), name));
}
if (null != diagnosticFileDumper) {
logger.trace(format("Channel %s getConfigurationBlock returned %s", name,
diagnosticFileDumper.createDiagnosticFile(String.valueOf(configBlock).getBytes())));
}
if (!logger.isTraceEnabled()) {
logger.debug(format("Channel %s getConfigurationBlock returned", name));
}
return configBlock;
} catch (TransactionException e) {
logger.error(e.getMessage(), e);
throw e;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new TransactionException(e);
}
}
|
java
|
private Block getConfigurationBlock() throws TransactionException {
logger.debug(format("getConfigurationBlock for channel %s", name));
try {
Orderer orderer = getRandomOrderer();
long lastConfigIndex = getLastConfigIndex(orderer);
logger.debug(format("Last config index is %d", lastConfigIndex));
Block configBlock = getBlockByNumber(lastConfigIndex);
//Little extra parsing but make sure this really is a config block for this channel.
Envelope envelopeRet = Envelope.parseFrom(configBlock.getData().getData(0));
Payload payload = Payload.parseFrom(envelopeRet.getPayload());
ChannelHeader channelHeader = ChannelHeader.parseFrom(payload.getHeader().getChannelHeader());
if (channelHeader.getType() != HeaderType.CONFIG.getNumber()) {
throw new TransactionException(format("Bad last configuration block type %d, expected %d",
channelHeader.getType(), HeaderType.CONFIG.getNumber()));
}
if (!name.equals(channelHeader.getChannelId())) {
throw new TransactionException(format("Bad last configuration block channel id %s, expected %s",
channelHeader.getChannelId(), name));
}
if (null != diagnosticFileDumper) {
logger.trace(format("Channel %s getConfigurationBlock returned %s", name,
diagnosticFileDumper.createDiagnosticFile(String.valueOf(configBlock).getBytes())));
}
if (!logger.isTraceEnabled()) {
logger.debug(format("Channel %s getConfigurationBlock returned", name));
}
return configBlock;
} catch (TransactionException e) {
logger.error(e.getMessage(), e);
throw e;
} catch (Exception e) {
logger.error(e.getMessage(), e);
throw new TransactionException(e);
}
}
|
[
"private",
"Block",
"getConfigurationBlock",
"(",
")",
"throws",
"TransactionException",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"getConfigurationBlock for channel %s\"",
",",
"name",
")",
")",
";",
"try",
"{",
"Orderer",
"orderer",
"=",
"getRandomOrderer",
"(",
")",
";",
"long",
"lastConfigIndex",
"=",
"getLastConfigIndex",
"(",
"orderer",
")",
";",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Last config index is %d\"",
",",
"lastConfigIndex",
")",
")",
";",
"Block",
"configBlock",
"=",
"getBlockByNumber",
"(",
"lastConfigIndex",
")",
";",
"//Little extra parsing but make sure this really is a config block for this channel.",
"Envelope",
"envelopeRet",
"=",
"Envelope",
".",
"parseFrom",
"(",
"configBlock",
".",
"getData",
"(",
")",
".",
"getData",
"(",
"0",
")",
")",
";",
"Payload",
"payload",
"=",
"Payload",
".",
"parseFrom",
"(",
"envelopeRet",
".",
"getPayload",
"(",
")",
")",
";",
"ChannelHeader",
"channelHeader",
"=",
"ChannelHeader",
".",
"parseFrom",
"(",
"payload",
".",
"getHeader",
"(",
")",
".",
"getChannelHeader",
"(",
")",
")",
";",
"if",
"(",
"channelHeader",
".",
"getType",
"(",
")",
"!=",
"HeaderType",
".",
"CONFIG",
".",
"getNumber",
"(",
")",
")",
"{",
"throw",
"new",
"TransactionException",
"(",
"format",
"(",
"\"Bad last configuration block type %d, expected %d\"",
",",
"channelHeader",
".",
"getType",
"(",
")",
",",
"HeaderType",
".",
"CONFIG",
".",
"getNumber",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"name",
".",
"equals",
"(",
"channelHeader",
".",
"getChannelId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"TransactionException",
"(",
"format",
"(",
"\"Bad last configuration block channel id %s, expected %s\"",
",",
"channelHeader",
".",
"getChannelId",
"(",
")",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"diagnosticFileDumper",
")",
"{",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"Channel %s getConfigurationBlock returned %s\"",
",",
"name",
",",
"diagnosticFileDumper",
".",
"createDiagnosticFile",
"(",
"String",
".",
"valueOf",
"(",
"configBlock",
")",
".",
"getBytes",
"(",
")",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"logger",
".",
"isTraceEnabled",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s getConfigurationBlock returned\"",
",",
"name",
")",
")",
";",
"}",
"return",
"configBlock",
";",
"}",
"catch",
"(",
"TransactionException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"throw",
"new",
"TransactionException",
"(",
"e",
")",
";",
"}",
"}"
] |
Provide the Channel's latest raw Configuration Block.
@return Channel configuration block.
@throws TransactionException
|
[
"Provide",
"the",
"Channel",
"s",
"latest",
"raw",
"Configuration",
"Block",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2137-L2182
|
22,116
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendInstallProposal
|
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest)
throws ProposalException, InvalidArgumentException {
return sendInstallProposal(installProposalRequest, getChaincodePeers());
}
|
java
|
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest)
throws ProposalException, InvalidArgumentException {
return sendInstallProposal(installProposalRequest, getChaincodePeers());
}
|
[
"Collection",
"<",
"ProposalResponse",
">",
"sendInstallProposal",
"(",
"InstallProposalRequest",
"installProposalRequest",
")",
"throws",
"ProposalException",
",",
"InvalidArgumentException",
"{",
"return",
"sendInstallProposal",
"(",
"installProposalRequest",
",",
"getChaincodePeers",
"(",
")",
")",
";",
"}"
] |
Send install chaincode request proposal to all the channels on the peer.
@param installProposalRequest
@return
@throws ProposalException
@throws InvalidArgumentException
|
[
"Send",
"install",
"chaincode",
"request",
"proposal",
"to",
"all",
"the",
"channels",
"on",
"the",
"peer",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2512-L2516
|
22,117
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendInstallProposal
|
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest, Collection<Peer> peers)
throws ProposalException, InvalidArgumentException {
checkChannelState();
checkPeers(peers);
if (null == installProposalRequest) {
throw new InvalidArgumentException("InstallProposalRequest is null");
}
try {
TransactionContext transactionContext = getTransactionContext(installProposalRequest.getUserContext());
transactionContext.verify(false); // Install will have no signing cause it's not really targeted to a channel.
transactionContext.setProposalWaitTime(installProposalRequest.getProposalWaitTime());
InstallProposalBuilder installProposalbuilder = InstallProposalBuilder.newBuilder();
installProposalbuilder.context(transactionContext);
installProposalbuilder.setChaincodeLanguage(installProposalRequest.getChaincodeLanguage());
installProposalbuilder.chaincodeName(installProposalRequest.getChaincodeName());
installProposalbuilder.chaincodePath(installProposalRequest.getChaincodePath());
installProposalbuilder.chaincodeVersion(installProposalRequest.getChaincodeVersion());
installProposalbuilder.setChaincodeSource(installProposalRequest.getChaincodeSourceLocation());
installProposalbuilder.setChaincodeInputStream(installProposalRequest.getChaincodeInputStream());
installProposalbuilder.setChaincodeMetaInfLocation(installProposalRequest.getChaincodeMetaInfLocation());
FabricProposal.Proposal deploymentProposal = installProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
}
|
java
|
Collection<ProposalResponse> sendInstallProposal(InstallProposalRequest installProposalRequest, Collection<Peer> peers)
throws ProposalException, InvalidArgumentException {
checkChannelState();
checkPeers(peers);
if (null == installProposalRequest) {
throw new InvalidArgumentException("InstallProposalRequest is null");
}
try {
TransactionContext transactionContext = getTransactionContext(installProposalRequest.getUserContext());
transactionContext.verify(false); // Install will have no signing cause it's not really targeted to a channel.
transactionContext.setProposalWaitTime(installProposalRequest.getProposalWaitTime());
InstallProposalBuilder installProposalbuilder = InstallProposalBuilder.newBuilder();
installProposalbuilder.context(transactionContext);
installProposalbuilder.setChaincodeLanguage(installProposalRequest.getChaincodeLanguage());
installProposalbuilder.chaincodeName(installProposalRequest.getChaincodeName());
installProposalbuilder.chaincodePath(installProposalRequest.getChaincodePath());
installProposalbuilder.chaincodeVersion(installProposalRequest.getChaincodeVersion());
installProposalbuilder.setChaincodeSource(installProposalRequest.getChaincodeSourceLocation());
installProposalbuilder.setChaincodeInputStream(installProposalRequest.getChaincodeInputStream());
installProposalbuilder.setChaincodeMetaInfLocation(installProposalRequest.getChaincodeMetaInfLocation());
FabricProposal.Proposal deploymentProposal = installProposalbuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext);
} catch (Exception e) {
throw new ProposalException(e);
}
}
|
[
"Collection",
"<",
"ProposalResponse",
">",
"sendInstallProposal",
"(",
"InstallProposalRequest",
"installProposalRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"ProposalException",
",",
"InvalidArgumentException",
"{",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"if",
"(",
"null",
"==",
"installProposalRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"InstallProposalRequest is null\"",
")",
";",
"}",
"try",
"{",
"TransactionContext",
"transactionContext",
"=",
"getTransactionContext",
"(",
"installProposalRequest",
".",
"getUserContext",
"(",
")",
")",
";",
"transactionContext",
".",
"verify",
"(",
"false",
")",
";",
"// Install will have no signing cause it's not really targeted to a channel.",
"transactionContext",
".",
"setProposalWaitTime",
"(",
"installProposalRequest",
".",
"getProposalWaitTime",
"(",
")",
")",
";",
"InstallProposalBuilder",
"installProposalbuilder",
"=",
"InstallProposalBuilder",
".",
"newBuilder",
"(",
")",
";",
"installProposalbuilder",
".",
"context",
"(",
"transactionContext",
")",
";",
"installProposalbuilder",
".",
"setChaincodeLanguage",
"(",
"installProposalRequest",
".",
"getChaincodeLanguage",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"chaincodeName",
"(",
"installProposalRequest",
".",
"getChaincodeName",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"chaincodePath",
"(",
"installProposalRequest",
".",
"getChaincodePath",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"chaincodeVersion",
"(",
"installProposalRequest",
".",
"getChaincodeVersion",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"setChaincodeSource",
"(",
"installProposalRequest",
".",
"getChaincodeSourceLocation",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"setChaincodeInputStream",
"(",
"installProposalRequest",
".",
"getChaincodeInputStream",
"(",
")",
")",
";",
"installProposalbuilder",
".",
"setChaincodeMetaInfLocation",
"(",
"installProposalRequest",
".",
"getChaincodeMetaInfLocation",
"(",
")",
")",
";",
"FabricProposal",
".",
"Proposal",
"deploymentProposal",
"=",
"installProposalbuilder",
".",
"build",
"(",
")",
";",
"SignedProposal",
"signedProposal",
"=",
"getSignedProposal",
"(",
"transactionContext",
",",
"deploymentProposal",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"signedProposal",
",",
"transactionContext",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"e",
")",
";",
"}",
"}"
] |
Send install chaincode request proposal to the channel.
@param installProposalRequest
@param peers
@return
@throws ProposalException
@throws InvalidArgumentException
|
[
"Send",
"install",
"chaincode",
"request",
"proposal",
"to",
"the",
"channel",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2528-L2559
|
22,118
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByHash
|
public BlockInfo queryBlockByHash(byte[] blockHash) throws InvalidArgumentException, ProposalException {
return queryBlockByHash(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), blockHash);
}
|
java
|
public BlockInfo queryBlockByHash(byte[] blockHash) throws InvalidArgumentException, ProposalException {
return queryBlockByHash(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), blockHash);
}
|
[
"public",
"BlockInfo",
"queryBlockByHash",
"(",
"byte",
"[",
"]",
"blockHash",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByHash",
"(",
"getShuffledPeers",
"(",
"EnumSet",
".",
"of",
"(",
"PeerRole",
".",
"LEDGER_QUERY",
")",
")",
",",
"blockHash",
")",
";",
"}"
] |
query this channel for a Block by the block hash.
The request is retried on each peer on the channel till successful.
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param blockHash the hash of the Block in the chain
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException
@throws ProposalException
|
[
"query",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"block",
"hash",
".",
"The",
"request",
"is",
"retried",
"on",
"each",
"peer",
"on",
"the",
"channel",
"till",
"successful",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2654-L2656
|
22,119
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByHash
|
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash) throws InvalidArgumentException, ProposalException {
return queryBlockByHash(peers, blockHash, client.getUserContext());
}
|
java
|
public BlockInfo queryBlockByHash(Collection<Peer> peers, byte[] blockHash) throws InvalidArgumentException, ProposalException {
return queryBlockByHash(peers, blockHash, client.getUserContext());
}
|
[
"public",
"BlockInfo",
"queryBlockByHash",
"(",
"Collection",
"<",
"Peer",
">",
"peers",
",",
"byte",
"[",
"]",
"blockHash",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByHash",
"(",
"peers",
",",
"blockHash",
",",
"client",
".",
"getUserContext",
"(",
")",
")",
";",
"}"
] |
Query a peer in this channel for a Block by the block hash.
Each peer is tried until successful response.
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param peers the Peers to query.
@param blockHash the hash of the Block in the chain.
@return the {@link BlockInfo} with the given block Hash
@throws InvalidArgumentException if the channel is shutdown or any of the arguments are not valid.
@throws ProposalException if an error occurred processing the query.
|
[
"Query",
"a",
"peer",
"in",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"block",
"hash",
".",
"Each",
"peer",
"is",
"tried",
"until",
"successful",
"response",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2699-L2703
|
22,120
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByNumber
|
public BlockInfo queryBlockByNumber(long blockNumber) throws InvalidArgumentException, ProposalException {
return queryBlockByNumber(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), blockNumber);
}
|
java
|
public BlockInfo queryBlockByNumber(long blockNumber) throws InvalidArgumentException, ProposalException {
return queryBlockByNumber(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), blockNumber);
}
|
[
"public",
"BlockInfo",
"queryBlockByNumber",
"(",
"long",
"blockNumber",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByNumber",
"(",
"getShuffledPeers",
"(",
"EnumSet",
".",
"of",
"(",
"PeerRole",
".",
"LEDGER_QUERY",
")",
")",
",",
"blockNumber",
")",
";",
"}"
] |
query this channel for a Block by the blockNumber.
The request is retried on all peers till successful
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param blockNumber index of the Block in the chain
@return the {@link BlockInfo} with the given blockNumber
@throws InvalidArgumentException
@throws ProposalException
|
[
"query",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"blockNumber",
".",
"The",
"request",
"is",
"retried",
"on",
"all",
"peers",
"till",
"successful"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2850-L2852
|
22,121
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByNumber
|
public BlockInfo queryBlockByNumber(Peer peer, long blockNumber) throws InvalidArgumentException, ProposalException {
return queryBlockByNumber(Collections.singleton(peer), blockNumber);
}
|
java
|
public BlockInfo queryBlockByNumber(Peer peer, long blockNumber) throws InvalidArgumentException, ProposalException {
return queryBlockByNumber(Collections.singleton(peer), blockNumber);
}
|
[
"public",
"BlockInfo",
"queryBlockByNumber",
"(",
"Peer",
"peer",
",",
"long",
"blockNumber",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByNumber",
"(",
"Collections",
".",
"singleton",
"(",
"peer",
")",
",",
"blockNumber",
")",
";",
"}"
] |
Query a peer in this channel for a Block by the blockNumber
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param peer the peer to send the request to
@param blockNumber index of the Block in the chain
@return the {@link BlockInfo} with the given blockNumber
@throws InvalidArgumentException
@throws ProposalException
|
[
"Query",
"a",
"peer",
"in",
"this",
"channel",
"for",
"a",
"Block",
"by",
"the",
"blockNumber"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2879-L2883
|
22,122
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryBlockByTransactionID
|
public BlockInfo queryBlockByTransactionID(String txID) throws InvalidArgumentException, ProposalException {
return queryBlockByTransactionID(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), txID);
}
|
java
|
public BlockInfo queryBlockByTransactionID(String txID) throws InvalidArgumentException, ProposalException {
return queryBlockByTransactionID(getShuffledPeers(EnumSet.of(PeerRole.LEDGER_QUERY)), txID);
}
|
[
"public",
"BlockInfo",
"queryBlockByTransactionID",
"(",
"String",
"txID",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryBlockByTransactionID",
"(",
"getShuffledPeers",
"(",
"EnumSet",
".",
"of",
"(",
"PeerRole",
".",
"LEDGER_QUERY",
")",
")",
",",
"txID",
")",
";",
"}"
] |
query this channel for a Block by a TransactionID contained in the block
The request is tried on on each peer till successful.
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param txID the transactionID to query on
@return the {@link BlockInfo} for the Block containing the transaction
@throws InvalidArgumentException
@throws ProposalException
|
[
"query",
"this",
"channel",
"for",
"a",
"Block",
"by",
"a",
"TransactionID",
"contained",
"in",
"the",
"block",
"The",
"request",
"is",
"tried",
"on",
"on",
"each",
"peer",
"till",
"successful",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L2959-L2962
|
22,123
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendLifecycleCommitChaincodeDefinitionProposal
|
public Collection<LifecycleCommitChaincodeDefinitionProposalResponse> sendLifecycleCommitChaincodeDefinitionProposal(LifecycleCommitChaincodeDefinitionRequest lifecycleCommitChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == lifecycleCommitChaincodeDefinitionRequest) {
throw new InvalidArgumentException("The lifecycleCommitChaincodeDefinitionRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
if (IS_TRACE_LEVEL) {
String collectionData = "null";
final ChaincodeCollectionConfiguration chaincodeCollectionConfiguration = lifecycleCommitChaincodeDefinitionRequest.getChaincodeCollectionConfiguration();
if (null != chaincodeCollectionConfiguration) {
final byte[] asBytes = chaincodeCollectionConfiguration.getAsBytes();
if (null != asBytes) {
collectionData = toHexString(asBytes);
}
}
logger.trace(format("LifecycleCommitChaincodeDefinition channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s" +
", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s" +
", collectionConfiguration: %s",
name,
lifecycleCommitChaincodeDefinitionRequest.getSequence(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeName(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeVersion(),
lifecycleCommitChaincodeDefinitionRequest.isInitRequired() + "",
toHexString(lifecycleCommitChaincodeDefinitionRequest.getValidationParameter()),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeEndorsementPlugin(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeValidationPlugin(),
collectionData));
}
TransactionContext transactionContext = getTransactionContext(lifecycleCommitChaincodeDefinitionRequest);
LifecycleCommitChaincodeDefinitionProposalBuilder commitChaincodeDefinitionProposalBuilder = LifecycleCommitChaincodeDefinitionProposalBuilder.newBuilder();
commitChaincodeDefinitionProposalBuilder.context(transactionContext);
commitChaincodeDefinitionProposalBuilder.chaincodeName(lifecycleCommitChaincodeDefinitionRequest.getChaincodeName());
commitChaincodeDefinitionProposalBuilder.version(lifecycleCommitChaincodeDefinitionRequest.getChaincodeVersion());
commitChaincodeDefinitionProposalBuilder.sequence(lifecycleCommitChaincodeDefinitionRequest.getSequence());
Boolean initRequired = lifecycleCommitChaincodeDefinitionRequest.isInitRequired();
if (null != initRequired) {
commitChaincodeDefinitionProposalBuilder.initRequired(initRequired);
}
ByteString validationParameter = lifecycleCommitChaincodeDefinitionRequest.getValidationParameter();
if (null != validationParameter) {
commitChaincodeDefinitionProposalBuilder.setValidationParamter(validationParameter);
}
String chaincodeCodeEndorsementPlugin = lifecycleCommitChaincodeDefinitionRequest.getChaincodeEndorsementPlugin();
if (null != chaincodeCodeEndorsementPlugin) {
commitChaincodeDefinitionProposalBuilder.chaincodeCodeEndorsementPlugin(chaincodeCodeEndorsementPlugin);
}
String chaincodeCodeValidationPlugin = lifecycleCommitChaincodeDefinitionRequest.getChaincodeValidationPlugin();
if (null != chaincodeCodeValidationPlugin) {
commitChaincodeDefinitionProposalBuilder.chaincodeCodeValidationPlugin(chaincodeCodeValidationPlugin);
}
ChaincodeCollectionConfiguration chaincodeCollectionConfiguration = lifecycleCommitChaincodeDefinitionRequest.getChaincodeCollectionConfiguration();
if (null != chaincodeCollectionConfiguration) {
commitChaincodeDefinitionProposalBuilder.chaincodeCollectionConfiguration(chaincodeCollectionConfiguration.getCollectionConfigPackage());
}
FabricProposal.Proposal deploymentProposal = commitChaincodeDefinitionProposalBuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext, LifecycleCommitChaincodeDefinitionProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(e);
}
}
|
java
|
public Collection<LifecycleCommitChaincodeDefinitionProposalResponse> sendLifecycleCommitChaincodeDefinitionProposal(LifecycleCommitChaincodeDefinitionRequest lifecycleCommitChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == lifecycleCommitChaincodeDefinitionRequest) {
throw new InvalidArgumentException("The lifecycleCommitChaincodeDefinitionRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
if (IS_TRACE_LEVEL) {
String collectionData = "null";
final ChaincodeCollectionConfiguration chaincodeCollectionConfiguration = lifecycleCommitChaincodeDefinitionRequest.getChaincodeCollectionConfiguration();
if (null != chaincodeCollectionConfiguration) {
final byte[] asBytes = chaincodeCollectionConfiguration.getAsBytes();
if (null != asBytes) {
collectionData = toHexString(asBytes);
}
}
logger.trace(format("LifecycleCommitChaincodeDefinition channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s" +
", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s" +
", collectionConfiguration: %s",
name,
lifecycleCommitChaincodeDefinitionRequest.getSequence(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeName(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeVersion(),
lifecycleCommitChaincodeDefinitionRequest.isInitRequired() + "",
toHexString(lifecycleCommitChaincodeDefinitionRequest.getValidationParameter()),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeEndorsementPlugin(),
lifecycleCommitChaincodeDefinitionRequest.getChaincodeValidationPlugin(),
collectionData));
}
TransactionContext transactionContext = getTransactionContext(lifecycleCommitChaincodeDefinitionRequest);
LifecycleCommitChaincodeDefinitionProposalBuilder commitChaincodeDefinitionProposalBuilder = LifecycleCommitChaincodeDefinitionProposalBuilder.newBuilder();
commitChaincodeDefinitionProposalBuilder.context(transactionContext);
commitChaincodeDefinitionProposalBuilder.chaincodeName(lifecycleCommitChaincodeDefinitionRequest.getChaincodeName());
commitChaincodeDefinitionProposalBuilder.version(lifecycleCommitChaincodeDefinitionRequest.getChaincodeVersion());
commitChaincodeDefinitionProposalBuilder.sequence(lifecycleCommitChaincodeDefinitionRequest.getSequence());
Boolean initRequired = lifecycleCommitChaincodeDefinitionRequest.isInitRequired();
if (null != initRequired) {
commitChaincodeDefinitionProposalBuilder.initRequired(initRequired);
}
ByteString validationParameter = lifecycleCommitChaincodeDefinitionRequest.getValidationParameter();
if (null != validationParameter) {
commitChaincodeDefinitionProposalBuilder.setValidationParamter(validationParameter);
}
String chaincodeCodeEndorsementPlugin = lifecycleCommitChaincodeDefinitionRequest.getChaincodeEndorsementPlugin();
if (null != chaincodeCodeEndorsementPlugin) {
commitChaincodeDefinitionProposalBuilder.chaincodeCodeEndorsementPlugin(chaincodeCodeEndorsementPlugin);
}
String chaincodeCodeValidationPlugin = lifecycleCommitChaincodeDefinitionRequest.getChaincodeValidationPlugin();
if (null != chaincodeCodeValidationPlugin) {
commitChaincodeDefinitionProposalBuilder.chaincodeCodeValidationPlugin(chaincodeCodeValidationPlugin);
}
ChaincodeCollectionConfiguration chaincodeCollectionConfiguration = lifecycleCommitChaincodeDefinitionRequest.getChaincodeCollectionConfiguration();
if (null != chaincodeCollectionConfiguration) {
commitChaincodeDefinitionProposalBuilder.chaincodeCollectionConfiguration(chaincodeCollectionConfiguration.getCollectionConfigPackage());
}
FabricProposal.Proposal deploymentProposal = commitChaincodeDefinitionProposalBuilder.build();
SignedProposal signedProposal = getSignedProposal(transactionContext, deploymentProposal);
return sendProposalToPeers(peers, signedProposal, transactionContext, LifecycleCommitChaincodeDefinitionProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(e);
}
}
|
[
"public",
"Collection",
"<",
"LifecycleCommitChaincodeDefinitionProposalResponse",
">",
"sendLifecycleCommitChaincodeDefinitionProposal",
"(",
"LifecycleCommitChaincodeDefinitionRequest",
"lifecycleCommitChaincodeDefinitionRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"if",
"(",
"null",
"==",
"lifecycleCommitChaincodeDefinitionRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The lifecycleCommitChaincodeDefinitionRequest parameter can not be null.\"",
")",
";",
"}",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"try",
"{",
"if",
"(",
"IS_TRACE_LEVEL",
")",
"{",
"String",
"collectionData",
"=",
"\"null\"",
";",
"final",
"ChaincodeCollectionConfiguration",
"chaincodeCollectionConfiguration",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeCollectionConfiguration",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"chaincodeCollectionConfiguration",
")",
"{",
"final",
"byte",
"[",
"]",
"asBytes",
"=",
"chaincodeCollectionConfiguration",
".",
"getAsBytes",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"asBytes",
")",
"{",
"collectionData",
"=",
"toHexString",
"(",
"asBytes",
")",
";",
"}",
"}",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"LifecycleCommitChaincodeDefinition channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s\"",
"+",
"\", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s\"",
"+",
"\", collectionConfiguration: %s\"",
",",
"name",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getSequence",
"(",
")",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeName",
"(",
")",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeVersion",
"(",
")",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"isInitRequired",
"(",
")",
"+",
"\"\"",
",",
"toHexString",
"(",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getValidationParameter",
"(",
")",
")",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeEndorsementPlugin",
"(",
")",
",",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeValidationPlugin",
"(",
")",
",",
"collectionData",
")",
")",
";",
"}",
"TransactionContext",
"transactionContext",
"=",
"getTransactionContext",
"(",
"lifecycleCommitChaincodeDefinitionRequest",
")",
";",
"LifecycleCommitChaincodeDefinitionProposalBuilder",
"commitChaincodeDefinitionProposalBuilder",
"=",
"LifecycleCommitChaincodeDefinitionProposalBuilder",
".",
"newBuilder",
"(",
")",
";",
"commitChaincodeDefinitionProposalBuilder",
".",
"context",
"(",
"transactionContext",
")",
";",
"commitChaincodeDefinitionProposalBuilder",
".",
"chaincodeName",
"(",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeName",
"(",
")",
")",
";",
"commitChaincodeDefinitionProposalBuilder",
".",
"version",
"(",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeVersion",
"(",
")",
")",
";",
"commitChaincodeDefinitionProposalBuilder",
".",
"sequence",
"(",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getSequence",
"(",
")",
")",
";",
"Boolean",
"initRequired",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"isInitRequired",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"initRequired",
")",
"{",
"commitChaincodeDefinitionProposalBuilder",
".",
"initRequired",
"(",
"initRequired",
")",
";",
"}",
"ByteString",
"validationParameter",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getValidationParameter",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"validationParameter",
")",
"{",
"commitChaincodeDefinitionProposalBuilder",
".",
"setValidationParamter",
"(",
"validationParameter",
")",
";",
"}",
"String",
"chaincodeCodeEndorsementPlugin",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeEndorsementPlugin",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"chaincodeCodeEndorsementPlugin",
")",
"{",
"commitChaincodeDefinitionProposalBuilder",
".",
"chaincodeCodeEndorsementPlugin",
"(",
"chaincodeCodeEndorsementPlugin",
")",
";",
"}",
"String",
"chaincodeCodeValidationPlugin",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeValidationPlugin",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"chaincodeCodeValidationPlugin",
")",
"{",
"commitChaincodeDefinitionProposalBuilder",
".",
"chaincodeCodeValidationPlugin",
"(",
"chaincodeCodeValidationPlugin",
")",
";",
"}",
"ChaincodeCollectionConfiguration",
"chaincodeCollectionConfiguration",
"=",
"lifecycleCommitChaincodeDefinitionRequest",
".",
"getChaincodeCollectionConfiguration",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"chaincodeCollectionConfiguration",
")",
"{",
"commitChaincodeDefinitionProposalBuilder",
".",
"chaincodeCollectionConfiguration",
"(",
"chaincodeCollectionConfiguration",
".",
"getCollectionConfigPackage",
"(",
")",
")",
";",
"}",
"FabricProposal",
".",
"Proposal",
"deploymentProposal",
"=",
"commitChaincodeDefinitionProposalBuilder",
".",
"build",
"(",
")",
";",
"SignedProposal",
"signedProposal",
"=",
"getSignedProposal",
"(",
"transactionContext",
",",
"deploymentProposal",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"signedProposal",
",",
"transactionContext",
",",
"LifecycleCommitChaincodeDefinitionProposalResponse",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"e",
")",
";",
"}",
"}"
] |
Commit chaincode final approval to run on all organizations that have approved.
@param lifecycleCommitChaincodeDefinitionRequest The request see {@link LifecycleCommitChaincodeDefinitionRequest}
@param peers to send the request to.
@return A {@link LifecycleCommitChaincodeDefinitionProposalResponse}
@throws InvalidArgumentException
@throws ProposalException
|
[
"Commit",
"chaincode",
"final",
"approval",
"to",
"run",
"on",
"all",
"organizations",
"that",
"have",
"approved",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3543-L3620
|
22,124
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.lifecycleQueryNamespaceDefinitions
|
public Collection<LifecycleQueryNamespaceDefinitionsProposalResponse> lifecycleQueryNamespaceDefinitions(LifecycleQueryNamespaceDefinitionsRequest queryNamespaceDefinitionsRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == queryNamespaceDefinitionsRequest) {
throw new InvalidArgumentException("The queryNamespaceDefinitionsRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
logger.trace(format("lifecycleQueryNamespaceDefinitions channel: %s", name));
TransactionContext context = getTransactionContext(queryNamespaceDefinitionsRequest);
LifecycleQueryNamespaceDefinitionsBuilder q = LifecycleQueryNamespaceDefinitionsBuilder.newBuilder();
q.context(context);
SignedProposal qProposal = getSignedProposal(context, q.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryNamespaceDefinitionsProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(format("QueryNamespaceDefinitions %s channel failed. " + e.getMessage(), name), e);
}
}
|
java
|
public Collection<LifecycleQueryNamespaceDefinitionsProposalResponse> lifecycleQueryNamespaceDefinitions(LifecycleQueryNamespaceDefinitionsRequest queryNamespaceDefinitionsRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == queryNamespaceDefinitionsRequest) {
throw new InvalidArgumentException("The queryNamespaceDefinitionsRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
logger.trace(format("lifecycleQueryNamespaceDefinitions channel: %s", name));
TransactionContext context = getTransactionContext(queryNamespaceDefinitionsRequest);
LifecycleQueryNamespaceDefinitionsBuilder q = LifecycleQueryNamespaceDefinitionsBuilder.newBuilder();
q.context(context);
SignedProposal qProposal = getSignedProposal(context, q.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryNamespaceDefinitionsProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(format("QueryNamespaceDefinitions %s channel failed. " + e.getMessage(), name), e);
}
}
|
[
"public",
"Collection",
"<",
"LifecycleQueryNamespaceDefinitionsProposalResponse",
">",
"lifecycleQueryNamespaceDefinitions",
"(",
"LifecycleQueryNamespaceDefinitionsRequest",
"queryNamespaceDefinitionsRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"if",
"(",
"null",
"==",
"queryNamespaceDefinitionsRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The queryNamespaceDefinitionsRequest parameter can not be null.\"",
")",
";",
"}",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"try",
"{",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"lifecycleQueryNamespaceDefinitions channel: %s\"",
",",
"name",
")",
")",
";",
"TransactionContext",
"context",
"=",
"getTransactionContext",
"(",
"queryNamespaceDefinitionsRequest",
")",
";",
"LifecycleQueryNamespaceDefinitionsBuilder",
"q",
"=",
"LifecycleQueryNamespaceDefinitionsBuilder",
".",
"newBuilder",
"(",
")",
";",
"q",
".",
"context",
"(",
"context",
")",
";",
"SignedProposal",
"qProposal",
"=",
"getSignedProposal",
"(",
"context",
",",
"q",
".",
"build",
"(",
")",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"qProposal",
",",
"context",
",",
"LifecycleQueryNamespaceDefinitionsProposalResponse",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"QueryNamespaceDefinitions %s channel failed. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Query namespaces. Takes no specific arguments returns namespaces including chaincode names that have been committed.
@param queryNamespaceDefinitionsRequest the request see {@link LifecycleQueryNamespaceDefinitionsRequest}
@param peers to send the request.
@return A {@link LifecycleQueryNamespaceDefinitionsProposalResponse}
@throws InvalidArgumentException
@throws ProposalException
|
[
"Query",
"namespaces",
".",
"Takes",
"no",
"specific",
"arguments",
"returns",
"namespaces",
"including",
"chaincode",
"names",
"that",
"have",
"been",
"committed",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3701-L3725
|
22,125
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendLifecycleQueryApprovalStatusRequest
|
public Collection<LifecycleQueryApprovalStatusProposalResponse> sendLifecycleQueryApprovalStatusRequest(LifecycleQueryApprovalStatusRequest lifecycleQueryApprovalStatusRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == lifecycleQueryApprovalStatusRequest) {
throw new InvalidArgumentException("The lifecycleQueryApprovalStatusRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
if (IS_TRACE_LEVEL) {
String collectionData = "null";
final org.hyperledger.fabric.protos.common.Collection.CollectionConfigPackage chaincodeCollectionConfiguration = lifecycleQueryApprovalStatusRequest.getCollectionConfigPackage();
if (null != chaincodeCollectionConfiguration) {
final byte[] asBytes = chaincodeCollectionConfiguration.toByteArray();
if (null != asBytes) {
collectionData = toHexString(asBytes);
}
}
logger.trace(format("LifecycleQueryApprovalStatus channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s" +
", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s" +
", collectionConfiguration: %s",
name,
lifecycleQueryApprovalStatusRequest.getSequence(),
lifecycleQueryApprovalStatusRequest.getChaincodeName(),
lifecycleQueryApprovalStatusRequest.getChaincodeVersion(),
lifecycleQueryApprovalStatusRequest.isInitRequired() + "",
toHexString(lifecycleQueryApprovalStatusRequest.getValidationParameter()),
lifecycleQueryApprovalStatusRequest.getChaincodeEndorsementPlugin(),
lifecycleQueryApprovalStatusRequest.getChaincodeValidationPlugin(),
collectionData));
}
TransactionContext context = getTransactionContext(lifecycleQueryApprovalStatusRequest);
LifecycleQueryApprovalStatusBuilder lifecycleQueryApprovalStatusBuilder = LifecycleQueryApprovalStatusBuilder.newBuilder();
lifecycleQueryApprovalStatusBuilder.setSequence(lifecycleQueryApprovalStatusRequest.getSequence());
lifecycleQueryApprovalStatusBuilder.setName(lifecycleQueryApprovalStatusRequest.getChaincodeName());
lifecycleQueryApprovalStatusBuilder.setVersion(lifecycleQueryApprovalStatusRequest.getChaincodeVersion());
String endorsementPlugin = lifecycleQueryApprovalStatusRequest.getChaincodeEndorsementPlugin();
if (!isNullOrEmpty(endorsementPlugin)) {
lifecycleQueryApprovalStatusBuilder.setEndorsementPlugin(endorsementPlugin);
}
String validationPlugin = lifecycleQueryApprovalStatusRequest.getChaincodeValidationPlugin();
if (!isNullOrEmpty(validationPlugin)) {
lifecycleQueryApprovalStatusBuilder.setValidationPlugin(validationPlugin);
}
ByteString validationParameter = lifecycleQueryApprovalStatusRequest.getValidationParameter();
if (null != validationParameter) {
lifecycleQueryApprovalStatusBuilder.setValidationParameter(validationParameter);
}
org.hyperledger.fabric.protos.common.Collection.CollectionConfigPackage collectionConfigPackage = lifecycleQueryApprovalStatusRequest.getCollectionConfigPackage();
if (null != collectionConfigPackage) {
lifecycleQueryApprovalStatusBuilder.setCollections(collectionConfigPackage);
}
Boolean initRequired = lifecycleQueryApprovalStatusRequest.isInitRequired();
if (null != initRequired) {
lifecycleQueryApprovalStatusBuilder.setInitRequired(initRequired);
}
lifecycleQueryApprovalStatusBuilder.context(context);
SignedProposal qProposal = getSignedProposal(context, lifecycleQueryApprovalStatusBuilder.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryApprovalStatusProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(format("QueryNamespaceDefinitions %s channel failed. " + e.getMessage(), name), e);
}
}
|
java
|
public Collection<LifecycleQueryApprovalStatusProposalResponse> sendLifecycleQueryApprovalStatusRequest(LifecycleQueryApprovalStatusRequest lifecycleQueryApprovalStatusRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == lifecycleQueryApprovalStatusRequest) {
throw new InvalidArgumentException("The lifecycleQueryApprovalStatusRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
if (IS_TRACE_LEVEL) {
String collectionData = "null";
final org.hyperledger.fabric.protos.common.Collection.CollectionConfigPackage chaincodeCollectionConfiguration = lifecycleQueryApprovalStatusRequest.getCollectionConfigPackage();
if (null != chaincodeCollectionConfiguration) {
final byte[] asBytes = chaincodeCollectionConfiguration.toByteArray();
if (null != asBytes) {
collectionData = toHexString(asBytes);
}
}
logger.trace(format("LifecycleQueryApprovalStatus channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s" +
", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s" +
", collectionConfiguration: %s",
name,
lifecycleQueryApprovalStatusRequest.getSequence(),
lifecycleQueryApprovalStatusRequest.getChaincodeName(),
lifecycleQueryApprovalStatusRequest.getChaincodeVersion(),
lifecycleQueryApprovalStatusRequest.isInitRequired() + "",
toHexString(lifecycleQueryApprovalStatusRequest.getValidationParameter()),
lifecycleQueryApprovalStatusRequest.getChaincodeEndorsementPlugin(),
lifecycleQueryApprovalStatusRequest.getChaincodeValidationPlugin(),
collectionData));
}
TransactionContext context = getTransactionContext(lifecycleQueryApprovalStatusRequest);
LifecycleQueryApprovalStatusBuilder lifecycleQueryApprovalStatusBuilder = LifecycleQueryApprovalStatusBuilder.newBuilder();
lifecycleQueryApprovalStatusBuilder.setSequence(lifecycleQueryApprovalStatusRequest.getSequence());
lifecycleQueryApprovalStatusBuilder.setName(lifecycleQueryApprovalStatusRequest.getChaincodeName());
lifecycleQueryApprovalStatusBuilder.setVersion(lifecycleQueryApprovalStatusRequest.getChaincodeVersion());
String endorsementPlugin = lifecycleQueryApprovalStatusRequest.getChaincodeEndorsementPlugin();
if (!isNullOrEmpty(endorsementPlugin)) {
lifecycleQueryApprovalStatusBuilder.setEndorsementPlugin(endorsementPlugin);
}
String validationPlugin = lifecycleQueryApprovalStatusRequest.getChaincodeValidationPlugin();
if (!isNullOrEmpty(validationPlugin)) {
lifecycleQueryApprovalStatusBuilder.setValidationPlugin(validationPlugin);
}
ByteString validationParameter = lifecycleQueryApprovalStatusRequest.getValidationParameter();
if (null != validationParameter) {
lifecycleQueryApprovalStatusBuilder.setValidationParameter(validationParameter);
}
org.hyperledger.fabric.protos.common.Collection.CollectionConfigPackage collectionConfigPackage = lifecycleQueryApprovalStatusRequest.getCollectionConfigPackage();
if (null != collectionConfigPackage) {
lifecycleQueryApprovalStatusBuilder.setCollections(collectionConfigPackage);
}
Boolean initRequired = lifecycleQueryApprovalStatusRequest.isInitRequired();
if (null != initRequired) {
lifecycleQueryApprovalStatusBuilder.setInitRequired(initRequired);
}
lifecycleQueryApprovalStatusBuilder.context(context);
SignedProposal qProposal = getSignedProposal(context, lifecycleQueryApprovalStatusBuilder.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryApprovalStatusProposalResponse.class);
} catch (Exception e) {
throw new ProposalException(format("QueryNamespaceDefinitions %s channel failed. " + e.getMessage(), name), e);
}
}
|
[
"public",
"Collection",
"<",
"LifecycleQueryApprovalStatusProposalResponse",
">",
"sendLifecycleQueryApprovalStatusRequest",
"(",
"LifecycleQueryApprovalStatusRequest",
"lifecycleQueryApprovalStatusRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"if",
"(",
"null",
"==",
"lifecycleQueryApprovalStatusRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The lifecycleQueryApprovalStatusRequest parameter can not be null.\"",
")",
";",
"}",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"try",
"{",
"if",
"(",
"IS_TRACE_LEVEL",
")",
"{",
"String",
"collectionData",
"=",
"\"null\"",
";",
"final",
"org",
".",
"hyperledger",
".",
"fabric",
".",
"protos",
".",
"common",
".",
"Collection",
".",
"CollectionConfigPackage",
"chaincodeCollectionConfiguration",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"getCollectionConfigPackage",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"chaincodeCollectionConfiguration",
")",
"{",
"final",
"byte",
"[",
"]",
"asBytes",
"=",
"chaincodeCollectionConfiguration",
".",
"toByteArray",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"asBytes",
")",
"{",
"collectionData",
"=",
"toHexString",
"(",
"asBytes",
")",
";",
"}",
"}",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"LifecycleQueryApprovalStatus channel: %s, sequence: %d, chaincodeName: %s, chaincodeVersion: %s\"",
"+",
"\", isInitRequired: %s, validationParameter: '%s', endorsementPolicyPlugin: %s, validationPlugin: %s\"",
"+",
"\", collectionConfiguration: %s\"",
",",
"name",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"getSequence",
"(",
")",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeName",
"(",
")",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeVersion",
"(",
")",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"isInitRequired",
"(",
")",
"+",
"\"\"",
",",
"toHexString",
"(",
"lifecycleQueryApprovalStatusRequest",
".",
"getValidationParameter",
"(",
")",
")",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeEndorsementPlugin",
"(",
")",
",",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeValidationPlugin",
"(",
")",
",",
"collectionData",
")",
")",
";",
"}",
"TransactionContext",
"context",
"=",
"getTransactionContext",
"(",
"lifecycleQueryApprovalStatusRequest",
")",
";",
"LifecycleQueryApprovalStatusBuilder",
"lifecycleQueryApprovalStatusBuilder",
"=",
"LifecycleQueryApprovalStatusBuilder",
".",
"newBuilder",
"(",
")",
";",
"lifecycleQueryApprovalStatusBuilder",
".",
"setSequence",
"(",
"lifecycleQueryApprovalStatusRequest",
".",
"getSequence",
"(",
")",
")",
";",
"lifecycleQueryApprovalStatusBuilder",
".",
"setName",
"(",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeName",
"(",
")",
")",
";",
"lifecycleQueryApprovalStatusBuilder",
".",
"setVersion",
"(",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeVersion",
"(",
")",
")",
";",
"String",
"endorsementPlugin",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeEndorsementPlugin",
"(",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"endorsementPlugin",
")",
")",
"{",
"lifecycleQueryApprovalStatusBuilder",
".",
"setEndorsementPlugin",
"(",
"endorsementPlugin",
")",
";",
"}",
"String",
"validationPlugin",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"getChaincodeValidationPlugin",
"(",
")",
";",
"if",
"(",
"!",
"isNullOrEmpty",
"(",
"validationPlugin",
")",
")",
"{",
"lifecycleQueryApprovalStatusBuilder",
".",
"setValidationPlugin",
"(",
"validationPlugin",
")",
";",
"}",
"ByteString",
"validationParameter",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"getValidationParameter",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"validationParameter",
")",
"{",
"lifecycleQueryApprovalStatusBuilder",
".",
"setValidationParameter",
"(",
"validationParameter",
")",
";",
"}",
"org",
".",
"hyperledger",
".",
"fabric",
".",
"protos",
".",
"common",
".",
"Collection",
".",
"CollectionConfigPackage",
"collectionConfigPackage",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"getCollectionConfigPackage",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"collectionConfigPackage",
")",
"{",
"lifecycleQueryApprovalStatusBuilder",
".",
"setCollections",
"(",
"collectionConfigPackage",
")",
";",
"}",
"Boolean",
"initRequired",
"=",
"lifecycleQueryApprovalStatusRequest",
".",
"isInitRequired",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"initRequired",
")",
"{",
"lifecycleQueryApprovalStatusBuilder",
".",
"setInitRequired",
"(",
"initRequired",
")",
";",
"}",
"lifecycleQueryApprovalStatusBuilder",
".",
"context",
"(",
"context",
")",
";",
"SignedProposal",
"qProposal",
"=",
"getSignedProposal",
"(",
"context",
",",
"lifecycleQueryApprovalStatusBuilder",
".",
"build",
"(",
")",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"qProposal",
",",
"context",
",",
"LifecycleQueryApprovalStatusProposalResponse",
".",
"class",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"QueryNamespaceDefinitions %s channel failed. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Query approval status for all organizations.
@param lifecycleQueryApprovalStatusRequest The request see {@link LifecycleQueryApprovalStatusRequest}
@param peers Peers to send the request. Usually only need one.
@return A {@link LifecycleQueryApprovalStatusProposalResponse}
@throws InvalidArgumentException
@throws ProposalException
|
[
"Query",
"approval",
"status",
"for",
"all",
"organizations",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3736-L3816
|
22,126
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.lifecycleQueryChaincodeDefinition
|
public Collection<LifecycleQueryChaincodeDefinitionProposalResponse> lifecycleQueryChaincodeDefinition(
QueryLifecycleQueryChaincodeDefinitionRequest queryLifecycleQueryChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == queryLifecycleQueryChaincodeDefinitionRequest) {
throw new InvalidArgumentException("The queryLifecycleQueryChaincodeDefinitionRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
logger.trace(format("LifecycleQueryChaincodeDefinition channel: %s, chaincode name: %s", name, queryLifecycleQueryChaincodeDefinitionRequest.getChaincodeName()));
TransactionContext context = getTransactionContext(queryLifecycleQueryChaincodeDefinitionRequest);
LifecycleQueryChaincodeDefinitionBuilder lifecycleQueryChaincodeDefinitionBuilder = LifecycleQueryChaincodeDefinitionBuilder.newBuilder();
lifecycleQueryChaincodeDefinitionBuilder.context(context).setChaincodeName(queryLifecycleQueryChaincodeDefinitionRequest.getChaincodeName());
SignedProposal qProposal = getSignedProposal(context, lifecycleQueryChaincodeDefinitionBuilder.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryChaincodeDefinitionProposalResponse.class);
} catch (ProposalException e) {
throw e;
} catch (Exception e) {
throw new ProposalException(format("Query for peer %s channels failed. " + e.getMessage(), name), e);
}
}
|
java
|
public Collection<LifecycleQueryChaincodeDefinitionProposalResponse> lifecycleQueryChaincodeDefinition(
QueryLifecycleQueryChaincodeDefinitionRequest queryLifecycleQueryChaincodeDefinitionRequest, Collection<Peer> peers) throws InvalidArgumentException, ProposalException {
if (null == queryLifecycleQueryChaincodeDefinitionRequest) {
throw new InvalidArgumentException("The queryLifecycleQueryChaincodeDefinitionRequest parameter can not be null.");
}
checkChannelState();
checkPeers(peers);
try {
logger.trace(format("LifecycleQueryChaincodeDefinition channel: %s, chaincode name: %s", name, queryLifecycleQueryChaincodeDefinitionRequest.getChaincodeName()));
TransactionContext context = getTransactionContext(queryLifecycleQueryChaincodeDefinitionRequest);
LifecycleQueryChaincodeDefinitionBuilder lifecycleQueryChaincodeDefinitionBuilder = LifecycleQueryChaincodeDefinitionBuilder.newBuilder();
lifecycleQueryChaincodeDefinitionBuilder.context(context).setChaincodeName(queryLifecycleQueryChaincodeDefinitionRequest.getChaincodeName());
SignedProposal qProposal = getSignedProposal(context, lifecycleQueryChaincodeDefinitionBuilder.build());
return sendProposalToPeers(peers, qProposal, context, LifecycleQueryChaincodeDefinitionProposalResponse.class);
} catch (ProposalException e) {
throw e;
} catch (Exception e) {
throw new ProposalException(format("Query for peer %s channels failed. " + e.getMessage(), name), e);
}
}
|
[
"public",
"Collection",
"<",
"LifecycleQueryChaincodeDefinitionProposalResponse",
">",
"lifecycleQueryChaincodeDefinition",
"(",
"QueryLifecycleQueryChaincodeDefinitionRequest",
"queryLifecycleQueryChaincodeDefinitionRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"if",
"(",
"null",
"==",
"queryLifecycleQueryChaincodeDefinitionRequest",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The queryLifecycleQueryChaincodeDefinitionRequest parameter can not be null.\"",
")",
";",
"}",
"checkChannelState",
"(",
")",
";",
"checkPeers",
"(",
"peers",
")",
";",
"try",
"{",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"LifecycleQueryChaincodeDefinition channel: %s, chaincode name: %s\"",
",",
"name",
",",
"queryLifecycleQueryChaincodeDefinitionRequest",
".",
"getChaincodeName",
"(",
")",
")",
")",
";",
"TransactionContext",
"context",
"=",
"getTransactionContext",
"(",
"queryLifecycleQueryChaincodeDefinitionRequest",
")",
";",
"LifecycleQueryChaincodeDefinitionBuilder",
"lifecycleQueryChaincodeDefinitionBuilder",
"=",
"LifecycleQueryChaincodeDefinitionBuilder",
".",
"newBuilder",
"(",
")",
";",
"lifecycleQueryChaincodeDefinitionBuilder",
".",
"context",
"(",
"context",
")",
".",
"setChaincodeName",
"(",
"queryLifecycleQueryChaincodeDefinitionRequest",
".",
"getChaincodeName",
"(",
")",
")",
";",
"SignedProposal",
"qProposal",
"=",
"getSignedProposal",
"(",
"context",
",",
"lifecycleQueryChaincodeDefinitionBuilder",
".",
"build",
"(",
")",
")",
";",
"return",
"sendProposalToPeers",
"(",
"peers",
",",
"qProposal",
",",
"context",
",",
"LifecycleQueryChaincodeDefinitionProposalResponse",
".",
"class",
")",
";",
"}",
"catch",
"(",
"ProposalException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Query for peer %s channels failed. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}"
] |
lifecycleQueryChaincodeDefinition get definition of chaincode.
@param queryLifecycleQueryChaincodeDefinitionRequest The request see {@link QueryLifecycleQueryChaincodeDefinitionRequest}
@param peers The peers to send the request to.
@return A {@link LifecycleQueryChaincodeDefinitionProposalResponse}
@throws InvalidArgumentException
@throws ProposalException
|
[
"lifecycleQueryChaincodeDefinition",
"get",
"definition",
"of",
"chaincode",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3828-L3855
|
22,127
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryInstantiatedChaincodes
|
public List<ChaincodeInfo> queryInstantiatedChaincodes(Peer peer) throws InvalidArgumentException, ProposalException {
return queryInstantiatedChaincodes(peer, client.getUserContext());
}
|
java
|
public List<ChaincodeInfo> queryInstantiatedChaincodes(Peer peer) throws InvalidArgumentException, ProposalException {
return queryInstantiatedChaincodes(peer, client.getUserContext());
}
|
[
"public",
"List",
"<",
"ChaincodeInfo",
">",
"queryInstantiatedChaincodes",
"(",
"Peer",
"peer",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"return",
"queryInstantiatedChaincodes",
"(",
"peer",
",",
"client",
".",
"getUserContext",
"(",
")",
")",
";",
"}"
] |
Query peer for chaincode that has been instantiated
<STRONG>This method may not be thread safe if client context is changed!</STRONG>
@param peer The peer to query.
@return A list of ChaincodeInfo @see {@link ChaincodeInfo}
@throws InvalidArgumentException
@throws ProposalException
|
[
"Query",
"peer",
"for",
"chaincode",
"that",
"has",
"been",
"instantiated"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3868-L3871
|
22,128
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.queryCollectionsConfig
|
public CollectionConfigPackage queryCollectionsConfig(String chaincodeName, Peer peer, User userContext) throws InvalidArgumentException, ProposalException {
if (isNullOrEmpty(chaincodeName)) {
throw new InvalidArgumentException("Parameter chaincodeName expected to be non null or empty string.");
}
checkChannelState();
checkPeer(peer);
User.userContextCheck(userContext);
try {
TransactionContext context = getTransactionContext(userContext);
QueryCollectionsConfigBuilder queryCollectionsConfigBuilder = QueryCollectionsConfigBuilder.newBuilder()
.context(context).chaincodeName(chaincodeName);
FabricProposal.Proposal q = queryCollectionsConfigBuilder.build();
SignedProposal qProposal = getSignedProposal(context, q);
Collection<ProposalResponse> proposalResponses = sendProposalToPeers(Collections.singletonList(peer), qProposal, context);
if (null == proposalResponses) {
throw new ProposalException(format("Peer %s channel query return with null for responses", peer.getName()));
}
if (proposalResponses.size() != 1) {
throw new ProposalException(format("Peer %s channel query expected one response but got back %d responses ", peer.getName(), proposalResponses.size()));
}
ProposalResponse proposalResponse = proposalResponses.iterator().next();
FabricProposalResponse.ProposalResponse fabricResponse = proposalResponse.getProposalResponse();
if (null == fabricResponse) {
throw new ProposalException(format("Peer %s channel query return with empty fabric response", peer.getName()));
}
final Response fabricResponseResponse = fabricResponse.getResponse();
if (null == fabricResponseResponse) { //not likely but check it.
throw new ProposalException(format("Peer %s channel query return with empty fabricResponseResponse", peer.getName()));
}
if (200 != fabricResponseResponse.getStatus()) {
throw new ProposalException(format("Peer %s channel query expected 200, actual returned was: %d. "
+ fabricResponseResponse.getMessage(), peer.getName(), fabricResponseResponse.getStatus()));
}
return new CollectionConfigPackage(fabricResponseResponse.getPayload());
} catch (ProposalException e) {
throw e;
} catch (Exception e) {
throw new ProposalException(format("Query for peer %s channels failed. " + e.getMessage(), name), e);
}
}
|
java
|
public CollectionConfigPackage queryCollectionsConfig(String chaincodeName, Peer peer, User userContext) throws InvalidArgumentException, ProposalException {
if (isNullOrEmpty(chaincodeName)) {
throw new InvalidArgumentException("Parameter chaincodeName expected to be non null or empty string.");
}
checkChannelState();
checkPeer(peer);
User.userContextCheck(userContext);
try {
TransactionContext context = getTransactionContext(userContext);
QueryCollectionsConfigBuilder queryCollectionsConfigBuilder = QueryCollectionsConfigBuilder.newBuilder()
.context(context).chaincodeName(chaincodeName);
FabricProposal.Proposal q = queryCollectionsConfigBuilder.build();
SignedProposal qProposal = getSignedProposal(context, q);
Collection<ProposalResponse> proposalResponses = sendProposalToPeers(Collections.singletonList(peer), qProposal, context);
if (null == proposalResponses) {
throw new ProposalException(format("Peer %s channel query return with null for responses", peer.getName()));
}
if (proposalResponses.size() != 1) {
throw new ProposalException(format("Peer %s channel query expected one response but got back %d responses ", peer.getName(), proposalResponses.size()));
}
ProposalResponse proposalResponse = proposalResponses.iterator().next();
FabricProposalResponse.ProposalResponse fabricResponse = proposalResponse.getProposalResponse();
if (null == fabricResponse) {
throw new ProposalException(format("Peer %s channel query return with empty fabric response", peer.getName()));
}
final Response fabricResponseResponse = fabricResponse.getResponse();
if (null == fabricResponseResponse) { //not likely but check it.
throw new ProposalException(format("Peer %s channel query return with empty fabricResponseResponse", peer.getName()));
}
if (200 != fabricResponseResponse.getStatus()) {
throw new ProposalException(format("Peer %s channel query expected 200, actual returned was: %d. "
+ fabricResponseResponse.getMessage(), peer.getName(), fabricResponseResponse.getStatus()));
}
return new CollectionConfigPackage(fabricResponseResponse.getPayload());
} catch (ProposalException e) {
throw e;
} catch (Exception e) {
throw new ProposalException(format("Query for peer %s channels failed. " + e.getMessage(), name), e);
}
}
|
[
"public",
"CollectionConfigPackage",
"queryCollectionsConfig",
"(",
"String",
"chaincodeName",
",",
"Peer",
"peer",
",",
"User",
"userContext",
")",
"throws",
"InvalidArgumentException",
",",
"ProposalException",
"{",
"if",
"(",
"isNullOrEmpty",
"(",
"chaincodeName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Parameter chaincodeName expected to be non null or empty string.\"",
")",
";",
"}",
"checkChannelState",
"(",
")",
";",
"checkPeer",
"(",
"peer",
")",
";",
"User",
".",
"userContextCheck",
"(",
"userContext",
")",
";",
"try",
"{",
"TransactionContext",
"context",
"=",
"getTransactionContext",
"(",
"userContext",
")",
";",
"QueryCollectionsConfigBuilder",
"queryCollectionsConfigBuilder",
"=",
"QueryCollectionsConfigBuilder",
".",
"newBuilder",
"(",
")",
".",
"context",
"(",
"context",
")",
".",
"chaincodeName",
"(",
"chaincodeName",
")",
";",
"FabricProposal",
".",
"Proposal",
"q",
"=",
"queryCollectionsConfigBuilder",
".",
"build",
"(",
")",
";",
"SignedProposal",
"qProposal",
"=",
"getSignedProposal",
"(",
"context",
",",
"q",
")",
";",
"Collection",
"<",
"ProposalResponse",
">",
"proposalResponses",
"=",
"sendProposalToPeers",
"(",
"Collections",
".",
"singletonList",
"(",
"peer",
")",
",",
"qProposal",
",",
"context",
")",
";",
"if",
"(",
"null",
"==",
"proposalResponses",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Peer %s channel query return with null for responses\"",
",",
"peer",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"proposalResponses",
".",
"size",
"(",
")",
"!=",
"1",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Peer %s channel query expected one response but got back %d responses \"",
",",
"peer",
".",
"getName",
"(",
")",
",",
"proposalResponses",
".",
"size",
"(",
")",
")",
")",
";",
"}",
"ProposalResponse",
"proposalResponse",
"=",
"proposalResponses",
".",
"iterator",
"(",
")",
".",
"next",
"(",
")",
";",
"FabricProposalResponse",
".",
"ProposalResponse",
"fabricResponse",
"=",
"proposalResponse",
".",
"getProposalResponse",
"(",
")",
";",
"if",
"(",
"null",
"==",
"fabricResponse",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Peer %s channel query return with empty fabric response\"",
",",
"peer",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"final",
"Response",
"fabricResponseResponse",
"=",
"fabricResponse",
".",
"getResponse",
"(",
")",
";",
"if",
"(",
"null",
"==",
"fabricResponseResponse",
")",
"{",
"//not likely but check it.",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Peer %s channel query return with empty fabricResponseResponse\"",
",",
"peer",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"200",
"!=",
"fabricResponseResponse",
".",
"getStatus",
"(",
")",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Peer %s channel query expected 200, actual returned was: %d. \"",
"+",
"fabricResponseResponse",
".",
"getMessage",
"(",
")",
",",
"peer",
".",
"getName",
"(",
")",
",",
"fabricResponseResponse",
".",
"getStatus",
"(",
")",
")",
")",
";",
"}",
"return",
"new",
"CollectionConfigPackage",
"(",
"fabricResponseResponse",
".",
"getPayload",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ProposalException",
"e",
")",
"{",
"throw",
"e",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ProposalException",
"(",
"format",
"(",
"\"Query for peer %s channels failed. \"",
"+",
"e",
".",
"getMessage",
"(",
")",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}"
] |
Get information on the collections used by the chaincode.
@param chaincodeName The name of the chaincode to query.
@param peer Peer to query.
@param userContext The context of the user to sign the request.
@return CollectionConfigPackage with information on the collection used by the chaincode.
@throws InvalidArgumentException
@throws ProposalException
|
[
"Get",
"information",
"on",
"the",
"collections",
"used",
"by",
"the",
"chaincode",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L3951-L4010
|
22,129
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendTransactionProposal
|
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException {
return sendProposal(transactionProposalRequest, peers);
}
|
java
|
public Collection<ProposalResponse> sendTransactionProposal(TransactionProposalRequest transactionProposalRequest, Collection<Peer> peers) throws ProposalException, InvalidArgumentException {
return sendProposal(transactionProposalRequest, peers);
}
|
[
"public",
"Collection",
"<",
"ProposalResponse",
">",
"sendTransactionProposal",
"(",
"TransactionProposalRequest",
"transactionProposalRequest",
",",
"Collection",
"<",
"Peer",
">",
"peers",
")",
"throws",
"ProposalException",
",",
"InvalidArgumentException",
"{",
"return",
"sendProposal",
"(",
"transactionProposalRequest",
",",
"peers",
")",
";",
"}"
] |
Send a transaction proposal to specific peers.
@param transactionProposalRequest The transaction proposal to be sent to the peers.
@param peers
@return responses from peers.
@throws InvalidArgumentException
@throws ProposalException
|
[
"Send",
"a",
"transaction",
"proposal",
"to",
"specific",
"peers",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L4354-L4357
|
22,130
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendTransaction
|
public CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext) {
return sendTransaction(proposalResponses, getOrderers(), userContext);
}
|
java
|
public CompletableFuture<TransactionEvent> sendTransaction(Collection<ProposalResponse> proposalResponses, User userContext) {
return sendTransaction(proposalResponses, getOrderers(), userContext);
}
|
[
"public",
"CompletableFuture",
"<",
"TransactionEvent",
">",
"sendTransaction",
"(",
"Collection",
"<",
"ProposalResponse",
">",
"proposalResponses",
",",
"User",
"userContext",
")",
"{",
"return",
"sendTransaction",
"(",
"proposalResponses",
",",
"getOrderers",
"(",
")",
",",
"userContext",
")",
";",
"}"
] |
Send transaction to one of the orderers on the channel using a specific user context.
@param proposalResponses The proposal responses to be sent to the orderer.
@param userContext The usercontext used for signing transaction.
@return a future allowing access to the result of the transaction invocation once complete.
|
[
"Send",
"transaction",
"to",
"one",
"of",
"the",
"orderers",
"on",
"the",
"channel",
"using",
"a",
"specific",
"user",
"context",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L4631-L4635
|
22,131
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.sendTransaction
|
public CompletableFuture<TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers) {
return sendTransaction(proposalResponses, orderers, client.getUserContext());
}
|
java
|
public CompletableFuture<TransactionEvent> sendTransaction(Collection<? extends ProposalResponse> proposalResponses, Collection<Orderer> orderers) {
return sendTransaction(proposalResponses, orderers, client.getUserContext());
}
|
[
"public",
"CompletableFuture",
"<",
"TransactionEvent",
">",
"sendTransaction",
"(",
"Collection",
"<",
"?",
"extends",
"ProposalResponse",
">",
"proposalResponses",
",",
"Collection",
"<",
"Orderer",
">",
"orderers",
")",
"{",
"return",
"sendTransaction",
"(",
"proposalResponses",
",",
"orderers",
",",
"client",
".",
"getUserContext",
"(",
")",
")",
";",
"}"
] |
Send transaction to one of the specified orderers using the usercontext set on the client..
@param proposalResponses The proposal responses to be sent to the orderer
@param orderers The orderers to send the transaction to.
@return a future allowing access to the result of the transaction invocation once complete.
|
[
"Send",
"transaction",
"to",
"one",
"of",
"the",
"specified",
"orderers",
"using",
"the",
"usercontext",
"set",
"on",
"the",
"client",
".."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L4657-L4660
|
22,132
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.getRespData
|
private String getRespData(BroadcastResponse resp) {
StringBuilder respdata = new StringBuilder(400);
if (resp != null) {
Status status = resp.getStatus();
if (null != status) {
respdata.append(status.name());
respdata.append("-");
respdata.append(status.getNumber());
}
String info = resp.getInfo();
if (null != info && !info.isEmpty()) {
if (respdata.length() > 0) {
respdata.append(", ");
}
respdata.append("Additional information: ").append(info);
}
}
return respdata.toString();
}
|
java
|
private String getRespData(BroadcastResponse resp) {
StringBuilder respdata = new StringBuilder(400);
if (resp != null) {
Status status = resp.getStatus();
if (null != status) {
respdata.append(status.name());
respdata.append("-");
respdata.append(status.getNumber());
}
String info = resp.getInfo();
if (null != info && !info.isEmpty()) {
if (respdata.length() > 0) {
respdata.append(", ");
}
respdata.append("Additional information: ").append(info);
}
}
return respdata.toString();
}
|
[
"private",
"String",
"getRespData",
"(",
"BroadcastResponse",
"resp",
")",
"{",
"StringBuilder",
"respdata",
"=",
"new",
"StringBuilder",
"(",
"400",
")",
";",
"if",
"(",
"resp",
"!=",
"null",
")",
"{",
"Status",
"status",
"=",
"resp",
".",
"getStatus",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"status",
")",
"{",
"respdata",
".",
"append",
"(",
"status",
".",
"name",
"(",
")",
")",
";",
"respdata",
".",
"append",
"(",
"\"-\"",
")",
";",
"respdata",
".",
"append",
"(",
"status",
".",
"getNumber",
"(",
")",
")",
";",
"}",
"String",
"info",
"=",
"resp",
".",
"getInfo",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"info",
"&&",
"!",
"info",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"respdata",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"respdata",
".",
"append",
"(",
"\", \"",
")",
";",
"}",
"respdata",
".",
"append",
"(",
"\"Additional information: \"",
")",
".",
"append",
"(",
"info",
")",
";",
"}",
"}",
"return",
"respdata",
".",
"toString",
"(",
")",
";",
"}"
] |
Build response details
@param resp
@return
|
[
"Build",
"response",
"details"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5405-L5430
|
22,133
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.registerBlockListener
|
public String registerBlockListener(BlockListener listener) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == listener) {
throw new InvalidArgumentException("Listener parameter is null.");
}
String handle = new BL(listener).getHandle();
logger.trace(format("Register event BlockEvent listener %s", handle));
return handle;
}
|
java
|
public String registerBlockListener(BlockListener listener) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (null == listener) {
throw new InvalidArgumentException("Listener parameter is null.");
}
String handle = new BL(listener).getHandle();
logger.trace(format("Register event BlockEvent listener %s", handle));
return handle;
}
|
[
"public",
"String",
"registerBlockListener",
"(",
"BlockListener",
"listener",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"null",
"==",
"listener",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Listener parameter is null.\"",
")",
";",
"}",
"String",
"handle",
"=",
"new",
"BL",
"(",
"listener",
")",
".",
"getHandle",
"(",
")",
";",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"Register event BlockEvent listener %s\"",
",",
"handle",
")",
")",
";",
"return",
"handle",
";",
"}"
] |
Register a block listener.
@param listener function with single argument with type {@link BlockEvent}
@return The handle of the registered block listener.
@throws InvalidArgumentException if the channel is shutdown.
|
[
"Register",
"a",
"block",
"listener",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5489-L5505
|
22,134
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.unregisterBlockListener
|
public boolean unregisterBlockListener(String handle) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
checkHandle(BLOCK_LISTENER_TAG, handle);
logger.trace(format("Unregister BlockListener with handle %s.", handle));
LinkedHashMap<String, BL> lblockListeners = blockListeners;
if (lblockListeners == null) {
return false;
}
synchronized (lblockListeners) {
return null != lblockListeners.remove(handle);
}
}
|
java
|
public boolean unregisterBlockListener(String handle) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
checkHandle(BLOCK_LISTENER_TAG, handle);
logger.trace(format("Unregister BlockListener with handle %s.", handle));
LinkedHashMap<String, BL> lblockListeners = blockListeners;
if (lblockListeners == null) {
return false;
}
synchronized (lblockListeners) {
return null != lblockListeners.remove(handle);
}
}
|
[
"public",
"boolean",
"unregisterBlockListener",
"(",
"String",
"handle",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"checkHandle",
"(",
"BLOCK_LISTENER_TAG",
",",
"handle",
")",
";",
"logger",
".",
"trace",
"(",
"format",
"(",
"\"Unregister BlockListener with handle %s.\"",
",",
"handle",
")",
")",
";",
"LinkedHashMap",
"<",
"String",
",",
"BL",
">",
"lblockListeners",
"=",
"blockListeners",
";",
"if",
"(",
"lblockListeners",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"synchronized",
"(",
"lblockListeners",
")",
"{",
"return",
"null",
"!=",
"lblockListeners",
".",
"remove",
"(",
"handle",
")",
";",
"}",
"}"
] |
Unregister a block listener.
@param handle of Block listener to remove.
@return false if not found.
@throws InvalidArgumentException if the channel is shutdown or invalid arguments.
|
[
"Unregister",
"a",
"block",
"listener",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5576-L5595
|
22,135
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.registerTransactionListenerProcessor
|
private String registerTransactionListenerProcessor() throws InvalidArgumentException {
logger.debug(format("Channel %s registerTransactionListenerProcessor starting", name));
// Transaction listener is internal Block listener for transactions
return registerBlockListener(blockEvent -> {
HFClient lclient = client;
if (null == lclient || shutdown) { //can happen if were not quite shutdown
return;
}
final String source = blockEvent.getPeer() != null ? blockEvent.getPeer().toString() :
"not peer!";
logger.debug(format("is peer %b, is filtered: %b", blockEvent.getPeer() != null, blockEvent.isFiltered()));
final Iterable<TransactionEvent> transactionEvents = blockEvent.getTransactionEvents();
if (transactionEvents == null || !transactionEvents.iterator().hasNext()) {
// no transactions today we can assume it was a config or update block.
if (isLaterBlock(blockEvent.getBlockNumber())) {
ServiceDiscovery lserviceDiscovery = serviceDiscovery;
if (null != lserviceDiscovery) {
client.getExecutorService().execute(() -> lserviceDiscovery.fullNetworkDiscovery(true));
}
} else {
lclient.getExecutorService().execute(() -> {
try {
if (!shutdown) {
loadCACertificates(true);
}
} catch (Exception e) {
logger.warn(format("Channel %s failed to load certificates for an update", name), e);
}
});
}
return;
}
if (txListeners.isEmpty() || shutdown) {
return;
}
for (TransactionEvent transactionEvent : blockEvent.getTransactionEvents()) {
logger.debug(format("Channel %s got event from %s for transaction %s in block number: %d", name,
source, transactionEvent.getTransactionID(), blockEvent.getBlockNumber()));
List<TL> txL = new ArrayList<>(txListeners.size() + 2);
synchronized (txListeners) {
LinkedList<TL> list = txListeners.get(transactionEvent.getTransactionID());
if (null != list) {
txL.addAll(list);
}
}
for (TL l : txL) {
try {
// only if we get events from each eventhub on the channel fire the transactions event.
// if (getEventHubs().containsAll(l.eventReceived(transactionEvent.getEventHub()))) {
if (shutdown) {
break;
}
if (l.eventReceived(transactionEvent)) {
l.fire(transactionEvent);
}
} catch (Throwable e) {
logger.error(e); // Don't let one register stop rest.
}
}
}
});
}
|
java
|
private String registerTransactionListenerProcessor() throws InvalidArgumentException {
logger.debug(format("Channel %s registerTransactionListenerProcessor starting", name));
// Transaction listener is internal Block listener for transactions
return registerBlockListener(blockEvent -> {
HFClient lclient = client;
if (null == lclient || shutdown) { //can happen if were not quite shutdown
return;
}
final String source = blockEvent.getPeer() != null ? blockEvent.getPeer().toString() :
"not peer!";
logger.debug(format("is peer %b, is filtered: %b", blockEvent.getPeer() != null, blockEvent.isFiltered()));
final Iterable<TransactionEvent> transactionEvents = blockEvent.getTransactionEvents();
if (transactionEvents == null || !transactionEvents.iterator().hasNext()) {
// no transactions today we can assume it was a config or update block.
if (isLaterBlock(blockEvent.getBlockNumber())) {
ServiceDiscovery lserviceDiscovery = serviceDiscovery;
if (null != lserviceDiscovery) {
client.getExecutorService().execute(() -> lserviceDiscovery.fullNetworkDiscovery(true));
}
} else {
lclient.getExecutorService().execute(() -> {
try {
if (!shutdown) {
loadCACertificates(true);
}
} catch (Exception e) {
logger.warn(format("Channel %s failed to load certificates for an update", name), e);
}
});
}
return;
}
if (txListeners.isEmpty() || shutdown) {
return;
}
for (TransactionEvent transactionEvent : blockEvent.getTransactionEvents()) {
logger.debug(format("Channel %s got event from %s for transaction %s in block number: %d", name,
source, transactionEvent.getTransactionID(), blockEvent.getBlockNumber()));
List<TL> txL = new ArrayList<>(txListeners.size() + 2);
synchronized (txListeners) {
LinkedList<TL> list = txListeners.get(transactionEvent.getTransactionID());
if (null != list) {
txL.addAll(list);
}
}
for (TL l : txL) {
try {
// only if we get events from each eventhub on the channel fire the transactions event.
// if (getEventHubs().containsAll(l.eventReceived(transactionEvent.getEventHub()))) {
if (shutdown) {
break;
}
if (l.eventReceived(transactionEvent)) {
l.fire(transactionEvent);
}
} catch (Throwable e) {
logger.error(e); // Don't let one register stop rest.
}
}
}
});
}
|
[
"private",
"String",
"registerTransactionListenerProcessor",
"(",
")",
"throws",
"InvalidArgumentException",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s registerTransactionListenerProcessor starting\"",
",",
"name",
")",
")",
";",
"// Transaction listener is internal Block listener for transactions",
"return",
"registerBlockListener",
"(",
"blockEvent",
"->",
"{",
"HFClient",
"lclient",
"=",
"client",
";",
"if",
"(",
"null",
"==",
"lclient",
"||",
"shutdown",
")",
"{",
"//can happen if were not quite shutdown",
"return",
";",
"}",
"final",
"String",
"source",
"=",
"blockEvent",
".",
"getPeer",
"(",
")",
"!=",
"null",
"?",
"blockEvent",
".",
"getPeer",
"(",
")",
".",
"toString",
"(",
")",
":",
"\"not peer!\"",
";",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"is peer %b, is filtered: %b\"",
",",
"blockEvent",
".",
"getPeer",
"(",
")",
"!=",
"null",
",",
"blockEvent",
".",
"isFiltered",
"(",
")",
")",
")",
";",
"final",
"Iterable",
"<",
"TransactionEvent",
">",
"transactionEvents",
"=",
"blockEvent",
".",
"getTransactionEvents",
"(",
")",
";",
"if",
"(",
"transactionEvents",
"==",
"null",
"||",
"!",
"transactionEvents",
".",
"iterator",
"(",
")",
".",
"hasNext",
"(",
")",
")",
"{",
"// no transactions today we can assume it was a config or update block.",
"if",
"(",
"isLaterBlock",
"(",
"blockEvent",
".",
"getBlockNumber",
"(",
")",
")",
")",
"{",
"ServiceDiscovery",
"lserviceDiscovery",
"=",
"serviceDiscovery",
";",
"if",
"(",
"null",
"!=",
"lserviceDiscovery",
")",
"{",
"client",
".",
"getExecutorService",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"lserviceDiscovery",
".",
"fullNetworkDiscovery",
"(",
"true",
")",
")",
";",
"}",
"}",
"else",
"{",
"lclient",
".",
"getExecutorService",
"(",
")",
".",
"execute",
"(",
"(",
")",
"->",
"{",
"try",
"{",
"if",
"(",
"!",
"shutdown",
")",
"{",
"loadCACertificates",
"(",
"true",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"warn",
"(",
"format",
"(",
"\"Channel %s failed to load certificates for an update\"",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}",
")",
";",
"}",
"return",
";",
"}",
"if",
"(",
"txListeners",
".",
"isEmpty",
"(",
")",
"||",
"shutdown",
")",
"{",
"return",
";",
"}",
"for",
"(",
"TransactionEvent",
"transactionEvent",
":",
"blockEvent",
".",
"getTransactionEvents",
"(",
")",
")",
"{",
"logger",
".",
"debug",
"(",
"format",
"(",
"\"Channel %s got event from %s for transaction %s in block number: %d\"",
",",
"name",
",",
"source",
",",
"transactionEvent",
".",
"getTransactionID",
"(",
")",
",",
"blockEvent",
".",
"getBlockNumber",
"(",
")",
")",
")",
";",
"List",
"<",
"TL",
">",
"txL",
"=",
"new",
"ArrayList",
"<>",
"(",
"txListeners",
".",
"size",
"(",
")",
"+",
"2",
")",
";",
"synchronized",
"(",
"txListeners",
")",
"{",
"LinkedList",
"<",
"TL",
">",
"list",
"=",
"txListeners",
".",
"get",
"(",
"transactionEvent",
".",
"getTransactionID",
"(",
")",
")",
";",
"if",
"(",
"null",
"!=",
"list",
")",
"{",
"txL",
".",
"addAll",
"(",
"list",
")",
";",
"}",
"}",
"for",
"(",
"TL",
"l",
":",
"txL",
")",
"{",
"try",
"{",
"// only if we get events from each eventhub on the channel fire the transactions event.",
"// if (getEventHubs().containsAll(l.eventReceived(transactionEvent.getEventHub()))) {",
"if",
"(",
"shutdown",
")",
"{",
"break",
";",
"}",
"if",
"(",
"l",
".",
"eventReceived",
"(",
"transactionEvent",
")",
")",
"{",
"l",
".",
"fire",
"(",
"transactionEvent",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
")",
";",
"// Don't let one register stop rest.",
"}",
"}",
"}",
"}",
")",
";",
"}"
] |
Own block listener to manage transactions.
@return
|
[
"Own",
"block",
"listener",
"to",
"manage",
"transactions",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5718-L5800
|
22,136
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.registerTxListener
|
private CompletableFuture<TransactionEvent> registerTxListener(String txid, NOfEvents nOfEvents, boolean failFast) {
CompletableFuture<TransactionEvent> future = new CompletableFuture<>();
new TL(txid, future, nOfEvents, failFast);
return future;
}
|
java
|
private CompletableFuture<TransactionEvent> registerTxListener(String txid, NOfEvents nOfEvents, boolean failFast) {
CompletableFuture<TransactionEvent> future = new CompletableFuture<>();
new TL(txid, future, nOfEvents, failFast);
return future;
}
|
[
"private",
"CompletableFuture",
"<",
"TransactionEvent",
">",
"registerTxListener",
"(",
"String",
"txid",
",",
"NOfEvents",
"nOfEvents",
",",
"boolean",
"failFast",
")",
"{",
"CompletableFuture",
"<",
"TransactionEvent",
">",
"future",
"=",
"new",
"CompletableFuture",
"<>",
"(",
")",
";",
"new",
"TL",
"(",
"txid",
",",
"future",
",",
"nOfEvents",
",",
"failFast",
")",
";",
"return",
"future",
";",
"}"
] |
Register a transactionId that to get notification on when the event is seen in the block chain.
@param txid
@param nOfEvents
@return
|
[
"Register",
"a",
"transactionId",
"that",
"to",
"get",
"notification",
"on",
"when",
"the",
"event",
"is",
"seen",
"in",
"the",
"block",
"chain",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5862-L5870
|
22,137
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.registerChaincodeEventListener
|
public String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (chaincodeId == null) {
throw new InvalidArgumentException("The chaincodeId argument may not be null.");
}
if (eventName == null) {
throw new InvalidArgumentException("The eventName argument may not be null.");
}
if (chaincodeEventListener == null) {
throw new InvalidArgumentException("The chaincodeEventListener argument may not be null.");
}
ChaincodeEventListenerEntry chaincodeEventListenerEntry = new ChaincodeEventListenerEntry(chaincodeId, eventName, chaincodeEventListener);
synchronized (this) {
if (null == blh) {
blh = registerChaincodeListenerProcessor();
}
}
return chaincodeEventListenerEntry.handle;
}
|
java
|
public String registerChaincodeEventListener(Pattern chaincodeId, Pattern eventName, ChaincodeEventListener chaincodeEventListener) throws InvalidArgumentException {
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
if (chaincodeId == null) {
throw new InvalidArgumentException("The chaincodeId argument may not be null.");
}
if (eventName == null) {
throw new InvalidArgumentException("The eventName argument may not be null.");
}
if (chaincodeEventListener == null) {
throw new InvalidArgumentException("The chaincodeEventListener argument may not be null.");
}
ChaincodeEventListenerEntry chaincodeEventListenerEntry = new ChaincodeEventListenerEntry(chaincodeId, eventName, chaincodeEventListener);
synchronized (this) {
if (null == blh) {
blh = registerChaincodeListenerProcessor();
}
}
return chaincodeEventListenerEntry.handle;
}
|
[
"public",
"String",
"registerChaincodeEventListener",
"(",
"Pattern",
"chaincodeId",
",",
"Pattern",
"eventName",
",",
"ChaincodeEventListener",
"chaincodeEventListener",
")",
"throws",
"InvalidArgumentException",
"{",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"if",
"(",
"chaincodeId",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The chaincodeId argument may not be null.\"",
")",
";",
"}",
"if",
"(",
"eventName",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The eventName argument may not be null.\"",
")",
";",
"}",
"if",
"(",
"chaincodeEventListener",
"==",
"null",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"The chaincodeEventListener argument may not be null.\"",
")",
";",
"}",
"ChaincodeEventListenerEntry",
"chaincodeEventListenerEntry",
"=",
"new",
"ChaincodeEventListenerEntry",
"(",
"chaincodeId",
",",
"eventName",
",",
"chaincodeEventListener",
")",
";",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"null",
"==",
"blh",
")",
"{",
"blh",
"=",
"registerChaincodeListenerProcessor",
"(",
")",
";",
"}",
"}",
"return",
"chaincodeEventListenerEntry",
".",
"handle",
";",
"}"
] |
Register a chaincode event listener. Both chaincodeId pattern AND eventName pattern must match to invoke
the chaincodeEventListener
@param chaincodeId Java pattern for chaincode identifier also know as chaincode name. If ma
@param eventName Java pattern to match the event name.
@param chaincodeEventListener The listener to be invoked if both chaincodeId and eventName pattern matches.
@return Handle to be used to unregister the event listener {@link #unregisterChaincodeEventListener(String)}
@throws InvalidArgumentException
|
[
"Register",
"a",
"chaincode",
"event",
"listener",
".",
"Both",
"chaincodeId",
"pattern",
"AND",
"eventName",
"pattern",
"must",
"match",
"to",
"invoke",
"the",
"chaincodeEventListener"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5897-L5923
|
22,138
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.unregisterChaincodeEventListener
|
public boolean unregisterChaincodeEventListener(String handle) throws InvalidArgumentException {
boolean ret;
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
checkHandle(CHAINCODE_EVENTS_TAG, handle);
synchronized (chainCodeListeners) {
ret = null != chainCodeListeners.remove(handle);
}
synchronized (this) {
if (null != blh && chainCodeListeners.isEmpty()) {
unregisterBlockListener(blh);
blh = null;
}
}
return ret;
}
|
java
|
public boolean unregisterChaincodeEventListener(String handle) throws InvalidArgumentException {
boolean ret;
if (shutdown) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", name));
}
checkHandle(CHAINCODE_EVENTS_TAG, handle);
synchronized (chainCodeListeners) {
ret = null != chainCodeListeners.remove(handle);
}
synchronized (this) {
if (null != blh && chainCodeListeners.isEmpty()) {
unregisterBlockListener(blh);
blh = null;
}
}
return ret;
}
|
[
"public",
"boolean",
"unregisterChaincodeEventListener",
"(",
"String",
"handle",
")",
"throws",
"InvalidArgumentException",
"{",
"boolean",
"ret",
";",
"if",
"(",
"shutdown",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"name",
")",
")",
";",
"}",
"checkHandle",
"(",
"CHAINCODE_EVENTS_TAG",
",",
"handle",
")",
";",
"synchronized",
"(",
"chainCodeListeners",
")",
"{",
"ret",
"=",
"null",
"!=",
"chainCodeListeners",
".",
"remove",
"(",
"handle",
")",
";",
"}",
"synchronized",
"(",
"this",
")",
"{",
"if",
"(",
"null",
"!=",
"blh",
"&&",
"chainCodeListeners",
".",
"isEmpty",
"(",
")",
")",
"{",
"unregisterBlockListener",
"(",
"blh",
")",
";",
"blh",
"=",
"null",
";",
"}",
"}",
"return",
"ret",
";",
"}"
] |
Unregister an existing chaincode event listener.
@param handle Chaincode event listener handle to be unregistered.
@return True if the chaincode handler was found and removed.
@throws InvalidArgumentException
|
[
"Unregister",
"an",
"existing",
"chaincode",
"event",
"listener",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L5933-L5957
|
22,139
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.shutdown
|
public synchronized void shutdown(boolean force) {
if (shutdown) {
return;
}
String ltransactionListenerProcessorHandle = transactionListenerProcessorHandle;
transactionListenerProcessorHandle = null;
if (null != ltransactionListenerProcessorHandle) {
try {
unregisterBlockListener(ltransactionListenerProcessorHandle);
} catch (Exception e) {
logger.error(format("Shutting down channel %s transactionListenerProcessorHandle", name), e);
}
}
String lchaincodeEventUpgradeListenerHandle = chaincodeEventUpgradeListenerHandle;
chaincodeEventUpgradeListenerHandle = null;
if (null != lchaincodeEventUpgradeListenerHandle) {
try {
unregisterChaincodeEventListener(lchaincodeEventUpgradeListenerHandle);
} catch (Exception e) {
logger.error(format("Shutting down channel %s chaincodeEventUpgradeListenr", name), e);
}
}
initialized = false;
shutdown = true;
final ServiceDiscovery lserviceDiscovery = serviceDiscovery;
serviceDiscovery = null;
if (null != lserviceDiscovery) {
lserviceDiscovery.shutdown();
}
if (chainCodeListeners != null) {
chainCodeListeners.clear();
}
if (blockListeners != null) {
blockListeners.clear();
}
if (client != null) {
client.removeChannel(this);
}
client = null;
for (Peer peer : new ArrayList<>(getPeers())) {
try {
removePeerInternal(peer);
peer.shutdown(force);
} catch (Exception e) {
// Best effort.
}
}
peers.clear(); // make sure.
peerEndpointMap.clear();
ordererEndpointMap.clear();
//Make sure
for (Set<Peer> peerRoleSet : peerRoleSetMap.values()) {
peerRoleSet.clear();
}
for (Orderer orderer : getOrderers()) {
orderer.shutdown(force);
}
orderers.clear();
if (null != eventQueueThread) {
eventQueueThread.interrupt();
eventQueueThread = null;
}
ScheduledFuture<?> lsweeper = sweeper;
sweeper = null;
if (null != lsweeper) {
lsweeper.cancel(true);
}
ScheduledExecutorService lse = sweeperExecutorService;
sweeperExecutorService = null;
if (null != lse) {
lse.shutdownNow();
}
}
|
java
|
public synchronized void shutdown(boolean force) {
if (shutdown) {
return;
}
String ltransactionListenerProcessorHandle = transactionListenerProcessorHandle;
transactionListenerProcessorHandle = null;
if (null != ltransactionListenerProcessorHandle) {
try {
unregisterBlockListener(ltransactionListenerProcessorHandle);
} catch (Exception e) {
logger.error(format("Shutting down channel %s transactionListenerProcessorHandle", name), e);
}
}
String lchaincodeEventUpgradeListenerHandle = chaincodeEventUpgradeListenerHandle;
chaincodeEventUpgradeListenerHandle = null;
if (null != lchaincodeEventUpgradeListenerHandle) {
try {
unregisterChaincodeEventListener(lchaincodeEventUpgradeListenerHandle);
} catch (Exception e) {
logger.error(format("Shutting down channel %s chaincodeEventUpgradeListenr", name), e);
}
}
initialized = false;
shutdown = true;
final ServiceDiscovery lserviceDiscovery = serviceDiscovery;
serviceDiscovery = null;
if (null != lserviceDiscovery) {
lserviceDiscovery.shutdown();
}
if (chainCodeListeners != null) {
chainCodeListeners.clear();
}
if (blockListeners != null) {
blockListeners.clear();
}
if (client != null) {
client.removeChannel(this);
}
client = null;
for (Peer peer : new ArrayList<>(getPeers())) {
try {
removePeerInternal(peer);
peer.shutdown(force);
} catch (Exception e) {
// Best effort.
}
}
peers.clear(); // make sure.
peerEndpointMap.clear();
ordererEndpointMap.clear();
//Make sure
for (Set<Peer> peerRoleSet : peerRoleSetMap.values()) {
peerRoleSet.clear();
}
for (Orderer orderer : getOrderers()) {
orderer.shutdown(force);
}
orderers.clear();
if (null != eventQueueThread) {
eventQueueThread.interrupt();
eventQueueThread = null;
}
ScheduledFuture<?> lsweeper = sweeper;
sweeper = null;
if (null != lsweeper) {
lsweeper.cancel(true);
}
ScheduledExecutorService lse = sweeperExecutorService;
sweeperExecutorService = null;
if (null != lse) {
lse.shutdownNow();
}
}
|
[
"public",
"synchronized",
"void",
"shutdown",
"(",
"boolean",
"force",
")",
"{",
"if",
"(",
"shutdown",
")",
"{",
"return",
";",
"}",
"String",
"ltransactionListenerProcessorHandle",
"=",
"transactionListenerProcessorHandle",
";",
"transactionListenerProcessorHandle",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"ltransactionListenerProcessorHandle",
")",
"{",
"try",
"{",
"unregisterBlockListener",
"(",
"ltransactionListenerProcessorHandle",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"format",
"(",
"\"Shutting down channel %s transactionListenerProcessorHandle\"",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}",
"String",
"lchaincodeEventUpgradeListenerHandle",
"=",
"chaincodeEventUpgradeListenerHandle",
";",
"chaincodeEventUpgradeListenerHandle",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"lchaincodeEventUpgradeListenerHandle",
")",
"{",
"try",
"{",
"unregisterChaincodeEventListener",
"(",
"lchaincodeEventUpgradeListenerHandle",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"format",
"(",
"\"Shutting down channel %s chaincodeEventUpgradeListenr\"",
",",
"name",
")",
",",
"e",
")",
";",
"}",
"}",
"initialized",
"=",
"false",
";",
"shutdown",
"=",
"true",
";",
"final",
"ServiceDiscovery",
"lserviceDiscovery",
"=",
"serviceDiscovery",
";",
"serviceDiscovery",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"lserviceDiscovery",
")",
"{",
"lserviceDiscovery",
".",
"shutdown",
"(",
")",
";",
"}",
"if",
"(",
"chainCodeListeners",
"!=",
"null",
")",
"{",
"chainCodeListeners",
".",
"clear",
"(",
")",
";",
"}",
"if",
"(",
"blockListeners",
"!=",
"null",
")",
"{",
"blockListeners",
".",
"clear",
"(",
")",
";",
"}",
"if",
"(",
"client",
"!=",
"null",
")",
"{",
"client",
".",
"removeChannel",
"(",
"this",
")",
";",
"}",
"client",
"=",
"null",
";",
"for",
"(",
"Peer",
"peer",
":",
"new",
"ArrayList",
"<>",
"(",
"getPeers",
"(",
")",
")",
")",
"{",
"try",
"{",
"removePeerInternal",
"(",
"peer",
")",
";",
"peer",
".",
"shutdown",
"(",
"force",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"// Best effort.",
"}",
"}",
"peers",
".",
"clear",
"(",
")",
";",
"// make sure.",
"peerEndpointMap",
".",
"clear",
"(",
")",
";",
"ordererEndpointMap",
".",
"clear",
"(",
")",
";",
"//Make sure",
"for",
"(",
"Set",
"<",
"Peer",
">",
"peerRoleSet",
":",
"peerRoleSetMap",
".",
"values",
"(",
")",
")",
"{",
"peerRoleSet",
".",
"clear",
"(",
")",
";",
"}",
"for",
"(",
"Orderer",
"orderer",
":",
"getOrderers",
"(",
")",
")",
"{",
"orderer",
".",
"shutdown",
"(",
"force",
")",
";",
"}",
"orderers",
".",
"clear",
"(",
")",
";",
"if",
"(",
"null",
"!=",
"eventQueueThread",
")",
"{",
"eventQueueThread",
".",
"interrupt",
"(",
")",
";",
"eventQueueThread",
"=",
"null",
";",
"}",
"ScheduledFuture",
"<",
"?",
">",
"lsweeper",
"=",
"sweeper",
";",
"sweeper",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"lsweeper",
")",
"{",
"lsweeper",
".",
"cancel",
"(",
"true",
")",
";",
"}",
"ScheduledExecutorService",
"lse",
"=",
"sweeperExecutorService",
";",
"sweeperExecutorService",
"=",
"null",
";",
"if",
"(",
"null",
"!=",
"lse",
")",
"{",
"lse",
".",
"shutdownNow",
"(",
")",
";",
"}",
"}"
] |
Shutdown the channel with all resources released.
@param force force immediate shutdown.
|
[
"Shutdown",
"the",
"channel",
"with",
"all",
"resources",
"released",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L6042-L6135
|
22,140
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.serializeChannel
|
public void serializeChannel(File file) throws IOException, InvalidArgumentException {
if (null == file) {
throw new InvalidArgumentException("File parameter may not be null");
}
Files.write(Paths.get(file.getAbsolutePath()), serializeChannel(),
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
}
|
java
|
public void serializeChannel(File file) throws IOException, InvalidArgumentException {
if (null == file) {
throw new InvalidArgumentException("File parameter may not be null");
}
Files.write(Paths.get(file.getAbsolutePath()), serializeChannel(),
StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
}
|
[
"public",
"void",
"serializeChannel",
"(",
"File",
"file",
")",
"throws",
"IOException",
",",
"InvalidArgumentException",
"{",
"if",
"(",
"null",
"==",
"file",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"File parameter may not be null\"",
")",
";",
"}",
"Files",
".",
"write",
"(",
"Paths",
".",
"get",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
",",
"serializeChannel",
"(",
")",
",",
"StandardOpenOption",
".",
"CREATE",
",",
"StandardOpenOption",
".",
"TRUNCATE_EXISTING",
",",
"StandardOpenOption",
".",
"WRITE",
")",
";",
"}"
] |
Serialize channel to a file using Java serialization.
Deserialized channel will NOT be in an initialized state.
@param file file
@throws IOException
@throws InvalidArgumentException
|
[
"Serialize",
"channel",
"to",
"a",
"file",
"using",
"Java",
"serialization",
".",
"Deserialized",
"channel",
"will",
"NOT",
"be",
"in",
"an",
"initialized",
"state",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L6146-L6155
|
22,141
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/Channel.java
|
Channel.serializeChannel
|
public byte[] serializeChannel() throws IOException, InvalidArgumentException {
if (isShutdown()) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", getName()));
}
ObjectOutputStream out = null;
try {
ByteArrayOutputStream bai = new ByteArrayOutputStream();
out = new ObjectOutputStream(bai);
out.writeObject(this);
out.flush();
return bai.toByteArray();
} finally {
if (null != out) {
try {
out.close();
} catch (IOException e) {
logger.error(e); // best effort.
}
}
}
}
|
java
|
public byte[] serializeChannel() throws IOException, InvalidArgumentException {
if (isShutdown()) {
throw new InvalidArgumentException(format("Channel %s has been shutdown.", getName()));
}
ObjectOutputStream out = null;
try {
ByteArrayOutputStream bai = new ByteArrayOutputStream();
out = new ObjectOutputStream(bai);
out.writeObject(this);
out.flush();
return bai.toByteArray();
} finally {
if (null != out) {
try {
out.close();
} catch (IOException e) {
logger.error(e); // best effort.
}
}
}
}
|
[
"public",
"byte",
"[",
"]",
"serializeChannel",
"(",
")",
"throws",
"IOException",
",",
"InvalidArgumentException",
"{",
"if",
"(",
"isShutdown",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"format",
"(",
"\"Channel %s has been shutdown.\"",
",",
"getName",
"(",
")",
")",
")",
";",
"}",
"ObjectOutputStream",
"out",
"=",
"null",
";",
"try",
"{",
"ByteArrayOutputStream",
"bai",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"out",
"=",
"new",
"ObjectOutputStream",
"(",
"bai",
")",
";",
"out",
".",
"writeObject",
"(",
"this",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"return",
"bai",
".",
"toByteArray",
"(",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"null",
"!=",
"out",
")",
"{",
"try",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logger",
".",
"error",
"(",
"e",
")",
";",
"// best effort.",
"}",
"}",
"}",
"}"
] |
Serialize channel to a byte array using Java serialization.
Deserialized channel will NOT be in an initialized state.
@throws InvalidArgumentException
@throws IOException
|
[
"Serialize",
"channel",
"to",
"a",
"byte",
"array",
"using",
"Java",
"serialization",
".",
"Deserialized",
"channel",
"will",
"NOT",
"be",
"in",
"an",
"initialized",
"state",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/Channel.java#L6164-L6188
|
22,142
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java
|
RevocationAuthority.getProofBytes
|
public static int getProofBytes(RevocationAlgorithm alg) {
if (alg == null) {
throw new IllegalArgumentException("Revocation algorithm cannot be null");
}
switch (alg) {
case ALG_NO_REVOCATION:
return 0;
default:
throw new IllegalArgumentException("Unsupported RevocationAlgorithm: " + alg.name());
}
}
|
java
|
public static int getProofBytes(RevocationAlgorithm alg) {
if (alg == null) {
throw new IllegalArgumentException("Revocation algorithm cannot be null");
}
switch (alg) {
case ALG_NO_REVOCATION:
return 0;
default:
throw new IllegalArgumentException("Unsupported RevocationAlgorithm: " + alg.name());
}
}
|
[
"public",
"static",
"int",
"getProofBytes",
"(",
"RevocationAlgorithm",
"alg",
")",
"{",
"if",
"(",
"alg",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Revocation algorithm cannot be null\"",
")",
";",
"}",
"switch",
"(",
"alg",
")",
"{",
"case",
"ALG_NO_REVOCATION",
":",
"return",
"0",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unsupported RevocationAlgorithm: \"",
"+",
"alg",
".",
"name",
"(",
")",
")",
";",
"}",
"}"
] |
Depending on the selected revocation algorithm, the proof data length will be different.
This method will give the proof length for any supported revocation algorithm.
@param alg The revocation algorithm
@return The proof data length for the given revocation algorithm
|
[
"Depending",
"on",
"the",
"selected",
"revocation",
"algorithm",
"the",
"proof",
"data",
"length",
"will",
"be",
"different",
".",
"This",
"method",
"will",
"give",
"the",
"proof",
"length",
"for",
"any",
"supported",
"revocation",
"algorithm",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java#L48-L58
|
22,143
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java
|
RevocationAuthority.generateLongTermRevocationKey
|
public static java.security.KeyPair generateLongTermRevocationKey() {
try {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
SecureRandom random = new SecureRandom();
AlgorithmParameterSpec params = new ECGenParameterSpec("secp384r1");
keyGen.initialize(params, random);
return keyGen.generateKeyPair();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
throw new RuntimeException("Error during the LTRevocation key. Invalid algorithm");
}
}
|
java
|
public static java.security.KeyPair generateLongTermRevocationKey() {
try {
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("EC");
SecureRandom random = new SecureRandom();
AlgorithmParameterSpec params = new ECGenParameterSpec("secp384r1");
keyGen.initialize(params, random);
return keyGen.generateKeyPair();
} catch (NoSuchAlgorithmException | InvalidAlgorithmParameterException e) {
throw new RuntimeException("Error during the LTRevocation key. Invalid algorithm");
}
}
|
[
"public",
"static",
"java",
".",
"security",
".",
"KeyPair",
"generateLongTermRevocationKey",
"(",
")",
"{",
"try",
"{",
"KeyPairGenerator",
"keyGen",
"=",
"KeyPairGenerator",
".",
"getInstance",
"(",
"\"EC\"",
")",
";",
"SecureRandom",
"random",
"=",
"new",
"SecureRandom",
"(",
")",
";",
"AlgorithmParameterSpec",
"params",
"=",
"new",
"ECGenParameterSpec",
"(",
"\"secp384r1\"",
")",
";",
"keyGen",
".",
"initialize",
"(",
"params",
",",
"random",
")",
";",
"return",
"keyGen",
".",
"generateKeyPair",
"(",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"|",
"InvalidAlgorithmParameterException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Error during the LTRevocation key. Invalid algorithm\"",
")",
";",
"}",
"}"
] |
Generate a long term ECDSA key pair used for revocation
@return Freshly generated ECDSA key pair
|
[
"Generate",
"a",
"long",
"term",
"ECDSA",
"key",
"pair",
"used",
"for",
"revocation"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java#L65-L76
|
22,144
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java
|
RevocationAuthority.createCRI
|
public static Idemix.CredentialRevocationInformation createCRI(PrivateKey key, BIG[] unrevokedHandles, int epoch, RevocationAlgorithm alg) throws CryptoException {
Idemix.CredentialRevocationInformation.Builder builder = Idemix.CredentialRevocationInformation.newBuilder();
builder.setRevocationAlg(alg.ordinal());
builder.setEpoch(epoch);
// Create epoch key
WeakBB.KeyPair keyPair = WeakBB.weakBBKeyGen();
if (alg == RevocationAlgorithm.ALG_NO_REVOCATION) {
// Dummy PK in the proto
builder.setEpochPk(IdemixUtils.transformToProto(IdemixUtils.genG2));
} else {
// Real PK only if we are going to use it
builder.setEpochPk(IdemixUtils.transformToProto(keyPair.getPk()));
}
// Sign epoch + epoch key with the long term key
byte[] signed;
try {
Idemix.CredentialRevocationInformation cri = builder.build();
Signature ecdsa = Signature.getInstance("SHA256withECDSA");
ecdsa.initSign(key);
ecdsa.update(cri.toByteArray());
signed = ecdsa.sign();
builder.setEpochPkSig(ByteString.copyFrom(signed));
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
throw new CryptoException("Error processing the signature");
}
if (alg == RevocationAlgorithm.ALG_NO_REVOCATION) {
// build and return the credential information object
return builder.build();
} else {
// If alg not supported, return null
throw new IllegalArgumentException("Algorithm " + alg.name() + " not supported");
}
}
|
java
|
public static Idemix.CredentialRevocationInformation createCRI(PrivateKey key, BIG[] unrevokedHandles, int epoch, RevocationAlgorithm alg) throws CryptoException {
Idemix.CredentialRevocationInformation.Builder builder = Idemix.CredentialRevocationInformation.newBuilder();
builder.setRevocationAlg(alg.ordinal());
builder.setEpoch(epoch);
// Create epoch key
WeakBB.KeyPair keyPair = WeakBB.weakBBKeyGen();
if (alg == RevocationAlgorithm.ALG_NO_REVOCATION) {
// Dummy PK in the proto
builder.setEpochPk(IdemixUtils.transformToProto(IdemixUtils.genG2));
} else {
// Real PK only if we are going to use it
builder.setEpochPk(IdemixUtils.transformToProto(keyPair.getPk()));
}
// Sign epoch + epoch key with the long term key
byte[] signed;
try {
Idemix.CredentialRevocationInformation cri = builder.build();
Signature ecdsa = Signature.getInstance("SHA256withECDSA");
ecdsa.initSign(key);
ecdsa.update(cri.toByteArray());
signed = ecdsa.sign();
builder.setEpochPkSig(ByteString.copyFrom(signed));
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
throw new CryptoException("Error processing the signature");
}
if (alg == RevocationAlgorithm.ALG_NO_REVOCATION) {
// build and return the credential information object
return builder.build();
} else {
// If alg not supported, return null
throw new IllegalArgumentException("Algorithm " + alg.name() + " not supported");
}
}
|
[
"public",
"static",
"Idemix",
".",
"CredentialRevocationInformation",
"createCRI",
"(",
"PrivateKey",
"key",
",",
"BIG",
"[",
"]",
"unrevokedHandles",
",",
"int",
"epoch",
",",
"RevocationAlgorithm",
"alg",
")",
"throws",
"CryptoException",
"{",
"Idemix",
".",
"CredentialRevocationInformation",
".",
"Builder",
"builder",
"=",
"Idemix",
".",
"CredentialRevocationInformation",
".",
"newBuilder",
"(",
")",
";",
"builder",
".",
"setRevocationAlg",
"(",
"alg",
".",
"ordinal",
"(",
")",
")",
";",
"builder",
".",
"setEpoch",
"(",
"epoch",
")",
";",
"// Create epoch key",
"WeakBB",
".",
"KeyPair",
"keyPair",
"=",
"WeakBB",
".",
"weakBBKeyGen",
"(",
")",
";",
"if",
"(",
"alg",
"==",
"RevocationAlgorithm",
".",
"ALG_NO_REVOCATION",
")",
"{",
"// Dummy PK in the proto",
"builder",
".",
"setEpochPk",
"(",
"IdemixUtils",
".",
"transformToProto",
"(",
"IdemixUtils",
".",
"genG2",
")",
")",
";",
"}",
"else",
"{",
"// Real PK only if we are going to use it",
"builder",
".",
"setEpochPk",
"(",
"IdemixUtils",
".",
"transformToProto",
"(",
"keyPair",
".",
"getPk",
"(",
")",
")",
")",
";",
"}",
"// Sign epoch + epoch key with the long term key",
"byte",
"[",
"]",
"signed",
";",
"try",
"{",
"Idemix",
".",
"CredentialRevocationInformation",
"cri",
"=",
"builder",
".",
"build",
"(",
")",
";",
"Signature",
"ecdsa",
"=",
"Signature",
".",
"getInstance",
"(",
"\"SHA256withECDSA\"",
")",
";",
"ecdsa",
".",
"initSign",
"(",
"key",
")",
";",
"ecdsa",
".",
"update",
"(",
"cri",
".",
"toByteArray",
"(",
")",
")",
";",
"signed",
"=",
"ecdsa",
".",
"sign",
"(",
")",
";",
"builder",
".",
"setEpochPkSig",
"(",
"ByteString",
".",
"copyFrom",
"(",
"signed",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"|",
"SignatureException",
"|",
"InvalidKeyException",
"e",
")",
"{",
"throw",
"new",
"CryptoException",
"(",
"\"Error processing the signature\"",
")",
";",
"}",
"if",
"(",
"alg",
"==",
"RevocationAlgorithm",
".",
"ALG_NO_REVOCATION",
")",
"{",
"// build and return the credential information object",
"return",
"builder",
".",
"build",
"(",
")",
";",
"}",
"else",
"{",
"// If alg not supported, return null",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Algorithm \"",
"+",
"alg",
".",
"name",
"(",
")",
"+",
"\" not supported\"",
")",
";",
"}",
"}"
] |
Creates a Credential Revocation Information object
@param key Private key
@param unrevokedHandles Array of unrevoked revocation handles
@param epoch The counter (representing a time window) in which this CRI is valid
@param alg Revocation algorithm
@return CredentialRevocationInformation object
|
[
"Creates",
"a",
"Credential",
"Revocation",
"Information",
"object"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java#L87-L123
|
22,145
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java
|
RevocationAuthority.verifyEpochPK
|
public static boolean verifyEpochPK(PublicKey pk, Idemix.ECP2 epochPK, byte[] epochPkSig, long epoch, RevocationAlgorithm alg) throws CryptoException {
Idemix.CredentialRevocationInformation.Builder builder = Idemix.CredentialRevocationInformation.newBuilder();
builder.setRevocationAlg(alg.ordinal());
builder.setEpochPk(epochPK);
builder.setEpoch(epoch);
Idemix.CredentialRevocationInformation cri = builder.build();
byte[] bytesTosign = cri.toByteArray();
try {
Signature dsa = Signature.getInstance("SHA256withECDSA");
dsa.initVerify(pk);
dsa.update(bytesTosign);
return dsa.verify(epochPkSig);
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
throw new CryptoException("Error during the EpochPK verification", e);
}
}
|
java
|
public static boolean verifyEpochPK(PublicKey pk, Idemix.ECP2 epochPK, byte[] epochPkSig, long epoch, RevocationAlgorithm alg) throws CryptoException {
Idemix.CredentialRevocationInformation.Builder builder = Idemix.CredentialRevocationInformation.newBuilder();
builder.setRevocationAlg(alg.ordinal());
builder.setEpochPk(epochPK);
builder.setEpoch(epoch);
Idemix.CredentialRevocationInformation cri = builder.build();
byte[] bytesTosign = cri.toByteArray();
try {
Signature dsa = Signature.getInstance("SHA256withECDSA");
dsa.initVerify(pk);
dsa.update(bytesTosign);
return dsa.verify(epochPkSig);
} catch (NoSuchAlgorithmException | SignatureException | InvalidKeyException e) {
throw new CryptoException("Error during the EpochPK verification", e);
}
}
|
[
"public",
"static",
"boolean",
"verifyEpochPK",
"(",
"PublicKey",
"pk",
",",
"Idemix",
".",
"ECP2",
"epochPK",
",",
"byte",
"[",
"]",
"epochPkSig",
",",
"long",
"epoch",
",",
"RevocationAlgorithm",
"alg",
")",
"throws",
"CryptoException",
"{",
"Idemix",
".",
"CredentialRevocationInformation",
".",
"Builder",
"builder",
"=",
"Idemix",
".",
"CredentialRevocationInformation",
".",
"newBuilder",
"(",
")",
";",
"builder",
".",
"setRevocationAlg",
"(",
"alg",
".",
"ordinal",
"(",
")",
")",
";",
"builder",
".",
"setEpochPk",
"(",
"epochPK",
")",
";",
"builder",
".",
"setEpoch",
"(",
"epoch",
")",
";",
"Idemix",
".",
"CredentialRevocationInformation",
"cri",
"=",
"builder",
".",
"build",
"(",
")",
";",
"byte",
"[",
"]",
"bytesTosign",
"=",
"cri",
".",
"toByteArray",
"(",
")",
";",
"try",
"{",
"Signature",
"dsa",
"=",
"Signature",
".",
"getInstance",
"(",
"\"SHA256withECDSA\"",
")",
";",
"dsa",
".",
"initVerify",
"(",
"pk",
")",
";",
"dsa",
".",
"update",
"(",
"bytesTosign",
")",
";",
"return",
"dsa",
".",
"verify",
"(",
"epochPkSig",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"|",
"SignatureException",
"|",
"InvalidKeyException",
"e",
")",
"{",
"throw",
"new",
"CryptoException",
"(",
"\"Error during the EpochPK verification\"",
",",
"e",
")",
";",
"}",
"}"
] |
Verifies that the revocation PK for a certain epoch is valid,
by checking that it was signed with the long term revocation key
@param pk Public Key
@param epochPK Epoch PK
@param epochPkSig Epoch PK Signature
@param epoch Epoch
@param alg Revocation algorithm
@return True if valid
|
[
"Verifies",
"that",
"the",
"revocation",
"PK",
"for",
"a",
"certain",
"epoch",
"is",
"valid",
"by",
"checking",
"that",
"it",
"was",
"signed",
"with",
"the",
"long",
"term",
"revocation",
"key"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/idemix/RevocationAuthority.java#L136-L152
|
22,146
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/identity/IdemixIdentity.java
|
IdemixIdentity.createSerializedIdentity
|
@Override
public Identities.SerializedIdentity createSerializedIdentity() {
MspPrincipal.OrganizationUnit ou = MspPrincipal.OrganizationUnit.newBuilder()
.setCertifiersIdentifier(ByteString.copyFrom(this.ipkHash))
.setMspIdentifier(this.mspId)
.setOrganizationalUnitIdentifier(this.ou)
.build();
//Warning, this does not support multi-roleMask.
//Serialize the bitmask is the correct way to support multi-roleMask in the future
MspPrincipal.MSPRole role = MspPrincipal.MSPRole.newBuilder()
.setRole(IdemixRoles.getMSPRoleFromIdemixRole(this.roleMask))
.setMspIdentifier(this.mspId)
.build();
Identities.SerializedIdemixIdentity serializedIdemixIdentity = Identities.SerializedIdemixIdentity.newBuilder()
.setProof(ByteString.copyFrom(this.associationProof.toProto().toByteArray()))
.setOu(ByteString.copyFrom(ou.toByteArray()))
.setRole(ByteString.copyFrom(role.toByteArray()))
.setNymY(ByteString.copyFrom(IdemixUtils.bigToBytes(this.pseudonym.getY())))
.setNymX(ByteString.copyFrom(IdemixUtils.bigToBytes(this.pseudonym.getX())))
.build();
return Identities.SerializedIdentity.newBuilder()
.setIdBytes(ByteString.copyFrom(serializedIdemixIdentity.toByteArray()))
.setMspid(this.mspId)
.build();
}
|
java
|
@Override
public Identities.SerializedIdentity createSerializedIdentity() {
MspPrincipal.OrganizationUnit ou = MspPrincipal.OrganizationUnit.newBuilder()
.setCertifiersIdentifier(ByteString.copyFrom(this.ipkHash))
.setMspIdentifier(this.mspId)
.setOrganizationalUnitIdentifier(this.ou)
.build();
//Warning, this does not support multi-roleMask.
//Serialize the bitmask is the correct way to support multi-roleMask in the future
MspPrincipal.MSPRole role = MspPrincipal.MSPRole.newBuilder()
.setRole(IdemixRoles.getMSPRoleFromIdemixRole(this.roleMask))
.setMspIdentifier(this.mspId)
.build();
Identities.SerializedIdemixIdentity serializedIdemixIdentity = Identities.SerializedIdemixIdentity.newBuilder()
.setProof(ByteString.copyFrom(this.associationProof.toProto().toByteArray()))
.setOu(ByteString.copyFrom(ou.toByteArray()))
.setRole(ByteString.copyFrom(role.toByteArray()))
.setNymY(ByteString.copyFrom(IdemixUtils.bigToBytes(this.pseudonym.getY())))
.setNymX(ByteString.copyFrom(IdemixUtils.bigToBytes(this.pseudonym.getX())))
.build();
return Identities.SerializedIdentity.newBuilder()
.setIdBytes(ByteString.copyFrom(serializedIdemixIdentity.toByteArray()))
.setMspid(this.mspId)
.build();
}
|
[
"@",
"Override",
"public",
"Identities",
".",
"SerializedIdentity",
"createSerializedIdentity",
"(",
")",
"{",
"MspPrincipal",
".",
"OrganizationUnit",
"ou",
"=",
"MspPrincipal",
".",
"OrganizationUnit",
".",
"newBuilder",
"(",
")",
".",
"setCertifiersIdentifier",
"(",
"ByteString",
".",
"copyFrom",
"(",
"this",
".",
"ipkHash",
")",
")",
".",
"setMspIdentifier",
"(",
"this",
".",
"mspId",
")",
".",
"setOrganizationalUnitIdentifier",
"(",
"this",
".",
"ou",
")",
".",
"build",
"(",
")",
";",
"//Warning, this does not support multi-roleMask.",
"//Serialize the bitmask is the correct way to support multi-roleMask in the future",
"MspPrincipal",
".",
"MSPRole",
"role",
"=",
"MspPrincipal",
".",
"MSPRole",
".",
"newBuilder",
"(",
")",
".",
"setRole",
"(",
"IdemixRoles",
".",
"getMSPRoleFromIdemixRole",
"(",
"this",
".",
"roleMask",
")",
")",
".",
"setMspIdentifier",
"(",
"this",
".",
"mspId",
")",
".",
"build",
"(",
")",
";",
"Identities",
".",
"SerializedIdemixIdentity",
"serializedIdemixIdentity",
"=",
"Identities",
".",
"SerializedIdemixIdentity",
".",
"newBuilder",
"(",
")",
".",
"setProof",
"(",
"ByteString",
".",
"copyFrom",
"(",
"this",
".",
"associationProof",
".",
"toProto",
"(",
")",
".",
"toByteArray",
"(",
")",
")",
")",
".",
"setOu",
"(",
"ByteString",
".",
"copyFrom",
"(",
"ou",
".",
"toByteArray",
"(",
")",
")",
")",
".",
"setRole",
"(",
"ByteString",
".",
"copyFrom",
"(",
"role",
".",
"toByteArray",
"(",
")",
")",
")",
".",
"setNymY",
"(",
"ByteString",
".",
"copyFrom",
"(",
"IdemixUtils",
".",
"bigToBytes",
"(",
"this",
".",
"pseudonym",
".",
"getY",
"(",
")",
")",
")",
")",
".",
"setNymX",
"(",
"ByteString",
".",
"copyFrom",
"(",
"IdemixUtils",
".",
"bigToBytes",
"(",
"this",
".",
"pseudonym",
".",
"getX",
"(",
")",
")",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"Identities",
".",
"SerializedIdentity",
".",
"newBuilder",
"(",
")",
".",
"setIdBytes",
"(",
"ByteString",
".",
"copyFrom",
"(",
"serializedIdemixIdentity",
".",
"toByteArray",
"(",
")",
")",
")",
".",
"setMspid",
"(",
"this",
".",
"mspId",
")",
".",
"build",
"(",
")",
";",
"}"
] |
Serialize Idemix Identity
|
[
"Serialize",
"Idemix",
"Identity"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/identity/IdemixIdentity.java#L155-L182
|
22,147
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric_ca/sdk/RegistrationRequest.java
|
RegistrationRequest.toJsonObject
|
JsonObject toJsonObject() {
JsonObjectBuilder ob = Json.createObjectBuilder();
ob.add("id", enrollmentID);
ob.add("type", type);
if (this.secret != null) {
ob.add("secret", secret);
}
if (null != maxEnrollments) {
ob.add("max_enrollments", maxEnrollments);
}
if (affiliation != null) {
ob.add("affiliation", affiliation);
}
JsonArrayBuilder ab = Json.createArrayBuilder();
for (Attribute attr : attrs) {
ab.add(attr.toJsonObject());
}
if (caName != null) {
ob.add(HFCAClient.FABRIC_CA_REQPROP, caName);
}
ob.add("attrs", ab.build());
return ob.build();
}
|
java
|
JsonObject toJsonObject() {
JsonObjectBuilder ob = Json.createObjectBuilder();
ob.add("id", enrollmentID);
ob.add("type", type);
if (this.secret != null) {
ob.add("secret", secret);
}
if (null != maxEnrollments) {
ob.add("max_enrollments", maxEnrollments);
}
if (affiliation != null) {
ob.add("affiliation", affiliation);
}
JsonArrayBuilder ab = Json.createArrayBuilder();
for (Attribute attr : attrs) {
ab.add(attr.toJsonObject());
}
if (caName != null) {
ob.add(HFCAClient.FABRIC_CA_REQPROP, caName);
}
ob.add("attrs", ab.build());
return ob.build();
}
|
[
"JsonObject",
"toJsonObject",
"(",
")",
"{",
"JsonObjectBuilder",
"ob",
"=",
"Json",
".",
"createObjectBuilder",
"(",
")",
";",
"ob",
".",
"add",
"(",
"\"id\"",
",",
"enrollmentID",
")",
";",
"ob",
".",
"add",
"(",
"\"type\"",
",",
"type",
")",
";",
"if",
"(",
"this",
".",
"secret",
"!=",
"null",
")",
"{",
"ob",
".",
"add",
"(",
"\"secret\"",
",",
"secret",
")",
";",
"}",
"if",
"(",
"null",
"!=",
"maxEnrollments",
")",
"{",
"ob",
".",
"add",
"(",
"\"max_enrollments\"",
",",
"maxEnrollments",
")",
";",
"}",
"if",
"(",
"affiliation",
"!=",
"null",
")",
"{",
"ob",
".",
"add",
"(",
"\"affiliation\"",
",",
"affiliation",
")",
";",
"}",
"JsonArrayBuilder",
"ab",
"=",
"Json",
".",
"createArrayBuilder",
"(",
")",
";",
"for",
"(",
"Attribute",
"attr",
":",
"attrs",
")",
"{",
"ab",
".",
"add",
"(",
"attr",
".",
"toJsonObject",
"(",
")",
")",
";",
"}",
"if",
"(",
"caName",
"!=",
"null",
")",
"{",
"ob",
".",
"add",
"(",
"HFCAClient",
".",
"FABRIC_CA_REQPROP",
",",
"caName",
")",
";",
"}",
"ob",
".",
"add",
"(",
"\"attrs\"",
",",
"ab",
".",
"build",
"(",
")",
")",
";",
"return",
"ob",
".",
"build",
"(",
")",
";",
"}"
] |
Convert the registration request to a JSON object
|
[
"Convert",
"the",
"registration",
"request",
"to",
"a",
"JSON",
"object"
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric_ca/sdk/RegistrationRequest.java#L147-L171
|
22,148
|
hyperledger/fabric-sdk-java
|
src/main/java/org/hyperledger/fabric/sdk/LifecycleQueryNamespaceDefinitionsProposalResponse.java
|
LifecycleQueryNamespaceDefinitionsProposalResponse.getChaincodeNamespaceTypes
|
public Collection<String> getChaincodeNamespaceTypes() throws ProposalException {
final Lifecycle.QueryNamespaceDefinitionsResult queryNamespaceDefinitionsResult = parsePayload();
if (queryNamespaceDefinitionsResult == null) {
return Collections.emptySet();
}
final Map<String, Lifecycle.QueryNamespaceDefinitionsResult.Namespace> namespacesMap = queryNamespaceDefinitionsResult.getNamespacesMap();
if (null == namespacesMap) {
return Collections.emptySet();
}
final Set<String> ret = new HashSet<>();
namespacesMap.forEach((s, namespace) -> {
if ("Chaincode".equalsIgnoreCase(namespace.getType())) {
ret.add(s);
}
});
return Collections.unmodifiableSet(ret);
}
|
java
|
public Collection<String> getChaincodeNamespaceTypes() throws ProposalException {
final Lifecycle.QueryNamespaceDefinitionsResult queryNamespaceDefinitionsResult = parsePayload();
if (queryNamespaceDefinitionsResult == null) {
return Collections.emptySet();
}
final Map<String, Lifecycle.QueryNamespaceDefinitionsResult.Namespace> namespacesMap = queryNamespaceDefinitionsResult.getNamespacesMap();
if (null == namespacesMap) {
return Collections.emptySet();
}
final Set<String> ret = new HashSet<>();
namespacesMap.forEach((s, namespace) -> {
if ("Chaincode".equalsIgnoreCase(namespace.getType())) {
ret.add(s);
}
});
return Collections.unmodifiableSet(ret);
}
|
[
"public",
"Collection",
"<",
"String",
">",
"getChaincodeNamespaceTypes",
"(",
")",
"throws",
"ProposalException",
"{",
"final",
"Lifecycle",
".",
"QueryNamespaceDefinitionsResult",
"queryNamespaceDefinitionsResult",
"=",
"parsePayload",
"(",
")",
";",
"if",
"(",
"queryNamespaceDefinitionsResult",
"==",
"null",
")",
"{",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}",
"final",
"Map",
"<",
"String",
",",
"Lifecycle",
".",
"QueryNamespaceDefinitionsResult",
".",
"Namespace",
">",
"namespacesMap",
"=",
"queryNamespaceDefinitionsResult",
".",
"getNamespacesMap",
"(",
")",
";",
"if",
"(",
"null",
"==",
"namespacesMap",
")",
"{",
"return",
"Collections",
".",
"emptySet",
"(",
")",
";",
"}",
"final",
"Set",
"<",
"String",
">",
"ret",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"namespacesMap",
".",
"forEach",
"(",
"(",
"s",
",",
"namespace",
")",
"->",
"{",
"if",
"(",
"\"Chaincode\"",
".",
"equalsIgnoreCase",
"(",
"namespace",
".",
"getType",
"(",
")",
")",
")",
"{",
"ret",
".",
"add",
"(",
"s",
")",
";",
"}",
"}",
")",
";",
"return",
"Collections",
".",
"unmodifiableSet",
"(",
"ret",
")",
";",
"}"
] |
The names of chaincode that have been committed.
@return The names of chaincode that have been committed.
@throws ProposalException
|
[
"The",
"names",
"of",
"chaincode",
"that",
"have",
"been",
"committed",
"."
] |
4a2d7b3408b8b0a1ed812aa36942c438159c37a0
|
https://github.com/hyperledger/fabric-sdk-java/blob/4a2d7b3408b8b0a1ed812aa36942c438159c37a0/src/main/java/org/hyperledger/fabric/sdk/LifecycleQueryNamespaceDefinitionsProposalResponse.java#L74-L94
|
22,149
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearAngleLines.java
|
RadialLinearAngleLines.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "display", this.display, false);
ChartUtils.writeDataValue(fsw, "color", this.color, true);
ChartUtils.writeDataValue(fsw, "lineWidth", this.lineWidth, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "display", this.display, false);
ChartUtils.writeDataValue(fsw, "color", this.color, true);
ChartUtils.writeDataValue(fsw, "lineWidth", this.lineWidth, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"\"{\"",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"display\"",
",",
"this",
".",
"display",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"color\"",
",",
"this",
".",
"color",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"lineWidth\"",
",",
"this",
".",
"lineWidth",
",",
"true",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of angled lines on radial linear type
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"angled",
"lines",
"on",
"radial",
"linear",
"type"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearAngleLines.java#L103-L120
|
22,150
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/imagecropper/ImageCropperRenderer.java
|
ImageCropperRenderer.guessImageFormat
|
private String guessImageFormat(String contentType, String imagePath) throws IOException {
String format = "png";
if (contentType == null) {
contentType = URLConnection.guessContentTypeFromName(imagePath);
}
if (contentType != null) {
format = contentType.replaceFirst("^image/([^;]+)[;]?.*$", "$1");
}
else {
int queryStringIndex = imagePath.indexOf('?');
if (queryStringIndex != -1) {
imagePath = imagePath.substring(0, queryStringIndex);
}
String[] pathTokens = imagePath.split("\\.");
if (pathTokens.length > 1) {
format = pathTokens[pathTokens.length - 1];
}
}
return format;
}
|
java
|
private String guessImageFormat(String contentType, String imagePath) throws IOException {
String format = "png";
if (contentType == null) {
contentType = URLConnection.guessContentTypeFromName(imagePath);
}
if (contentType != null) {
format = contentType.replaceFirst("^image/([^;]+)[;]?.*$", "$1");
}
else {
int queryStringIndex = imagePath.indexOf('?');
if (queryStringIndex != -1) {
imagePath = imagePath.substring(0, queryStringIndex);
}
String[] pathTokens = imagePath.split("\\.");
if (pathTokens.length > 1) {
format = pathTokens[pathTokens.length - 1];
}
}
return format;
}
|
[
"private",
"String",
"guessImageFormat",
"(",
"String",
"contentType",
",",
"String",
"imagePath",
")",
"throws",
"IOException",
"{",
"String",
"format",
"=",
"\"png\"",
";",
"if",
"(",
"contentType",
"==",
"null",
")",
"{",
"contentType",
"=",
"URLConnection",
".",
"guessContentTypeFromName",
"(",
"imagePath",
")",
";",
"}",
"if",
"(",
"contentType",
"!=",
"null",
")",
"{",
"format",
"=",
"contentType",
".",
"replaceFirst",
"(",
"\"^image/([^;]+)[;]?.*$\"",
",",
"\"$1\"",
")",
";",
"}",
"else",
"{",
"int",
"queryStringIndex",
"=",
"imagePath",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"queryStringIndex",
"!=",
"-",
"1",
")",
"{",
"imagePath",
"=",
"imagePath",
".",
"substring",
"(",
"0",
",",
"queryStringIndex",
")",
";",
"}",
"String",
"[",
"]",
"pathTokens",
"=",
"imagePath",
".",
"split",
"(",
"\"\\\\.\"",
")",
";",
"if",
"(",
"pathTokens",
".",
"length",
">",
"1",
")",
"{",
"format",
"=",
"pathTokens",
"[",
"pathTokens",
".",
"length",
"-",
"1",
"]",
";",
"}",
"}",
"return",
"format",
";",
"}"
] |
Attempt to obtain the image format used to write the image from the contentType or the image's file extension.
|
[
"Attempt",
"to",
"obtain",
"the",
"image",
"format",
"used",
"to",
"write",
"the",
"image",
"from",
"the",
"contentType",
"or",
"the",
"image",
"s",
"file",
"extension",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/imagecropper/ImageCropperRenderer.java#L281-L307
|
22,151
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ChartUtils.java
|
ChartUtils.writeDataValue
|
public static void writeDataValue(Writer fsw, String optionName, Object value, boolean hasComma) throws IOException {
if (value == null) {
return;
}
boolean isList = value instanceof List;
if (hasComma) {
fsw.write(",");
}
fsw.write("\"" + optionName + "\":");
if (isList) {
fsw.write("[");
for (int i = 0; i < ((List<?>) value).size(); i++) {
Object item = ((List<?>) value).get(i);
Object writeText;
if (item instanceof BubblePoint) {
BubblePoint point = (BubblePoint) item;
writeText = (i == 0) ? "" : ",";
writeText += "{\"x\":" + point.getX() + ",\"y\":" + point.getY() + ",\"r\":" + point.getR() + "}";
}
else if (item instanceof String) {
String escapedText = EscapeUtils.forJavaScript((String) item);
writeText = (i == 0) ? "\"" + escapedText + "\"" : ",\"" + escapedText + "\"";
}
else {
writeText = (i == 0) ? item : "," + item;
}
fsw.write("" + writeText);
}
fsw.write("]");
}
else {
if (value instanceof String) {
fsw.write("\"" + EscapeUtils.forJavaScript((String) value) + "\"");
}
else {
fsw.write("" + value);
}
}
}
|
java
|
public static void writeDataValue(Writer fsw, String optionName, Object value, boolean hasComma) throws IOException {
if (value == null) {
return;
}
boolean isList = value instanceof List;
if (hasComma) {
fsw.write(",");
}
fsw.write("\"" + optionName + "\":");
if (isList) {
fsw.write("[");
for (int i = 0; i < ((List<?>) value).size(); i++) {
Object item = ((List<?>) value).get(i);
Object writeText;
if (item instanceof BubblePoint) {
BubblePoint point = (BubblePoint) item;
writeText = (i == 0) ? "" : ",";
writeText += "{\"x\":" + point.getX() + ",\"y\":" + point.getY() + ",\"r\":" + point.getR() + "}";
}
else if (item instanceof String) {
String escapedText = EscapeUtils.forJavaScript((String) item);
writeText = (i == 0) ? "\"" + escapedText + "\"" : ",\"" + escapedText + "\"";
}
else {
writeText = (i == 0) ? item : "," + item;
}
fsw.write("" + writeText);
}
fsw.write("]");
}
else {
if (value instanceof String) {
fsw.write("\"" + EscapeUtils.forJavaScript((String) value) + "\"");
}
else {
fsw.write("" + value);
}
}
}
|
[
"public",
"static",
"void",
"writeDataValue",
"(",
"Writer",
"fsw",
",",
"String",
"optionName",
",",
"Object",
"value",
",",
"boolean",
"hasComma",
")",
"throws",
"IOException",
"{",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"return",
";",
"}",
"boolean",
"isList",
"=",
"value",
"instanceof",
"List",
";",
"if",
"(",
"hasComma",
")",
"{",
"fsw",
".",
"write",
"(",
"\",\"",
")",
";",
"}",
"fsw",
".",
"write",
"(",
"\"\\\"\"",
"+",
"optionName",
"+",
"\"\\\":\"",
")",
";",
"if",
"(",
"isList",
")",
"{",
"fsw",
".",
"write",
"(",
"\"[\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"(",
"(",
"List",
"<",
"?",
">",
")",
"value",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Object",
"item",
"=",
"(",
"(",
"List",
"<",
"?",
">",
")",
"value",
")",
".",
"get",
"(",
"i",
")",
";",
"Object",
"writeText",
";",
"if",
"(",
"item",
"instanceof",
"BubblePoint",
")",
"{",
"BubblePoint",
"point",
"=",
"(",
"BubblePoint",
")",
"item",
";",
"writeText",
"=",
"(",
"i",
"==",
"0",
")",
"?",
"\"\"",
":",
"\",\"",
";",
"writeText",
"+=",
"\"{\\\"x\\\":\"",
"+",
"point",
".",
"getX",
"(",
")",
"+",
"\",\\\"y\\\":\"",
"+",
"point",
".",
"getY",
"(",
")",
"+",
"\",\\\"r\\\":\"",
"+",
"point",
".",
"getR",
"(",
")",
"+",
"\"}\"",
";",
"}",
"else",
"if",
"(",
"item",
"instanceof",
"String",
")",
"{",
"String",
"escapedText",
"=",
"EscapeUtils",
".",
"forJavaScript",
"(",
"(",
"String",
")",
"item",
")",
";",
"writeText",
"=",
"(",
"i",
"==",
"0",
")",
"?",
"\"\\\"\"",
"+",
"escapedText",
"+",
"\"\\\"\"",
":",
"\",\\\"\"",
"+",
"escapedText",
"+",
"\"\\\"\"",
";",
"}",
"else",
"{",
"writeText",
"=",
"(",
"i",
"==",
"0",
")",
"?",
"item",
":",
"\",\"",
"+",
"item",
";",
"}",
"fsw",
".",
"write",
"(",
"\"\"",
"+",
"writeText",
")",
";",
"}",
"fsw",
".",
"write",
"(",
"\"]\"",
")",
";",
"}",
"else",
"{",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"fsw",
".",
"write",
"(",
"\"\\\"\"",
"+",
"EscapeUtils",
".",
"forJavaScript",
"(",
"(",
"String",
")",
"value",
")",
"+",
"\"\\\"\"",
")",
";",
"}",
"else",
"{",
"fsw",
".",
"write",
"(",
"\"\"",
"+",
"value",
")",
";",
"}",
"}",
"}"
] |
Write the value of chartJs options
@param fsw a writer object that use to write the value of an option
@param optionName the name of an option
@param value the value of an option
@param hasComma specifies whether to add a comma at the beginning of the option name
@throws java.io.IOException if writer named fsw is null
|
[
"Write",
"the",
"value",
"of",
"chartJs",
"options"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ChartUtils.java#L48-L91
|
22,152
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearTicks.java
|
RadialLinearTicks.encode
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
ChartUtils.writeDataValue(fsw, "backdropColor", this.backdropColor, true);
ChartUtils.writeDataValue(fsw, "backdropPaddingX", this.backdropPaddingX, true);
ChartUtils.writeDataValue(fsw, "backdropPaddingY", this.backdropPaddingY, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
ChartUtils.writeDataValue(fsw, "showLabelBackdrop", this.showLabelBackdrop, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
ChartUtils.writeDataValue(fsw, "backdropColor", this.backdropColor, true);
ChartUtils.writeDataValue(fsw, "backdropPaddingX", this.backdropPaddingX, true);
ChartUtils.writeDataValue(fsw, "backdropPaddingY", this.backdropPaddingY, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
ChartUtils.writeDataValue(fsw, "showLabelBackdrop", this.showLabelBackdrop, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"@",
"Override",
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"\"{\"",
")",
";",
"fsw",
".",
"write",
"(",
"super",
".",
"encode",
"(",
")",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"beginAtZero\"",
",",
"this",
".",
"beginAtZero",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backdropColor\"",
",",
"this",
".",
"backdropColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backdropPaddingX\"",
",",
"this",
".",
"backdropPaddingX",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backdropPaddingY\"",
",",
"this",
".",
"backdropPaddingY",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"min\"",
",",
"this",
".",
"min",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"max\"",
",",
"this",
".",
"max",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"maxTicksLimit\"",
",",
"this",
".",
"maxTicksLimit",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"stepSize\"",
",",
"this",
".",
"stepSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"suggestedMax\"",
",",
"this",
".",
"suggestedMax",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"suggestedMin\"",
",",
"this",
".",
"suggestedMin",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"showLabelBackdrop\"",
",",
"this",
".",
"showLabelBackdrop",
",",
"true",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the radial linear ticks
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"radial",
"linear",
"ticks"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearTicks.java#L255-L282
|
22,153
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsArc.java
|
ElementsArc.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, false);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, false);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderWidth\"",
",",
"this",
".",
"borderWidth",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backgroundColor\"",
",",
"this",
".",
"backgroundColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderColor\"",
",",
"this",
".",
"borderColor",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the arc options of Elements
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"arc",
"options",
"of",
"Elements"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsArc.java#L103-L116
|
22,154
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/CheckboxTreeNodeChildren.java
|
CheckboxTreeNodeChildren.setSibling
|
@Override
public TreeNode setSibling(int index, TreeNode node) {
if (node == null) {
throw new NullPointerException();
}
else if ((index < 0) || (index >= size())) {
throw new IndexOutOfBoundsException();
}
else {
if (!parent.equals(node.getParent())) {
eraseParent(node);
}
TreeNode previous = get(index);
super.set(index, node);
node.setParent(parent);
updateRowKeys(parent);
updateSelectionState(parent);
return previous;
}
}
|
java
|
@Override
public TreeNode setSibling(int index, TreeNode node) {
if (node == null) {
throw new NullPointerException();
}
else if ((index < 0) || (index >= size())) {
throw new IndexOutOfBoundsException();
}
else {
if (!parent.equals(node.getParent())) {
eraseParent(node);
}
TreeNode previous = get(index);
super.set(index, node);
node.setParent(parent);
updateRowKeys(parent);
updateSelectionState(parent);
return previous;
}
}
|
[
"@",
"Override",
"public",
"TreeNode",
"setSibling",
"(",
"int",
"index",
",",
"TreeNode",
"node",
")",
"{",
"if",
"(",
"node",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
")",
";",
"}",
"else",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">=",
"size",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"parent",
".",
"equals",
"(",
"node",
".",
"getParent",
"(",
")",
")",
")",
"{",
"eraseParent",
"(",
"node",
")",
";",
"}",
"TreeNode",
"previous",
"=",
"get",
"(",
"index",
")",
";",
"super",
".",
"set",
"(",
"index",
",",
"node",
")",
";",
"node",
".",
"setParent",
"(",
"parent",
")",
";",
"updateRowKeys",
"(",
"parent",
")",
";",
"updateSelectionState",
"(",
"parent",
")",
";",
"return",
"previous",
";",
"}",
"}"
] |
Optimized set implementation to be used in sorting
@param index index of the element to replace
@param node node to be stored at the specified position
@return the node previously at the specified position
|
[
"Optimized",
"set",
"implementation",
"to",
"be",
"used",
"in",
"sorting"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/CheckboxTreeNodeChildren.java#L160-L180
|
22,155
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/DateUtils.java
|
DateUtils.toLocalDate
|
public static long toLocalDate(TimeZone browserTZ, TimeZone targetTZ, Date utcDate) {
long utc = utcDate.getTime();
int targetOffsetFromUTC = targetTZ.getOffset(utc);
int browserOffsetFromUTC = browserTZ.getOffset(utc);
return utc + targetOffsetFromUTC - browserOffsetFromUTC;
}
|
java
|
public static long toLocalDate(TimeZone browserTZ, TimeZone targetTZ, Date utcDate) {
long utc = utcDate.getTime();
int targetOffsetFromUTC = targetTZ.getOffset(utc);
int browserOffsetFromUTC = browserTZ.getOffset(utc);
return utc + targetOffsetFromUTC - browserOffsetFromUTC;
}
|
[
"public",
"static",
"long",
"toLocalDate",
"(",
"TimeZone",
"browserTZ",
",",
"TimeZone",
"targetTZ",
",",
"Date",
"utcDate",
")",
"{",
"long",
"utc",
"=",
"utcDate",
".",
"getTime",
"(",
")",
";",
"int",
"targetOffsetFromUTC",
"=",
"targetTZ",
".",
"getOffset",
"(",
"utc",
")",
";",
"int",
"browserOffsetFromUTC",
"=",
"browserTZ",
".",
"getOffset",
"(",
"utc",
")",
";",
"return",
"utc",
"+",
"targetOffsetFromUTC",
"-",
"browserOffsetFromUTC",
";",
"}"
] |
convert from UTC to local date
|
[
"convert",
"from",
"UTC",
"to",
"local",
"date"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/DateUtils.java#L62-L68
|
22,156
|
primefaces/primefaces
|
src/main/java/org/primefaces/renderkit/InputRenderer.java
|
InputRenderer.renderARIARequired
|
protected void renderARIARequired(FacesContext context, UIInput component) throws IOException {
if (component.isRequired()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute(HTML.ARIA_REQUIRED, "true", null);
}
}
|
java
|
protected void renderARIARequired(FacesContext context, UIInput component) throws IOException {
if (component.isRequired()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute(HTML.ARIA_REQUIRED, "true", null);
}
}
|
[
"protected",
"void",
"renderARIARequired",
"(",
"FacesContext",
"context",
",",
"UIInput",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"component",
".",
"isRequired",
"(",
")",
")",
"{",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"writeAttribute",
"(",
"HTML",
".",
"ARIA_REQUIRED",
",",
"\"true\"",
",",
"null",
")",
";",
"}",
"}"
] |
Adds "aria-required" if the component is required.
@param context the {@link FacesContext}
@param component the {@link UIInput} component to add attributes for
@throws IOException if any error occurs writing the response
|
[
"Adds",
"aria",
"-",
"required",
"if",
"the",
"component",
"is",
"required",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/renderkit/InputRenderer.java#L81-L86
|
22,157
|
primefaces/primefaces
|
src/main/java/org/primefaces/renderkit/InputRenderer.java
|
InputRenderer.renderARIAInvalid
|
protected void renderARIAInvalid(FacesContext context, UIInput component) throws IOException {
if (!component.isValid()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute(HTML.ARIA_INVALID, "true", null);
}
}
|
java
|
protected void renderARIAInvalid(FacesContext context, UIInput component) throws IOException {
if (!component.isValid()) {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute(HTML.ARIA_INVALID, "true", null);
}
}
|
[
"protected",
"void",
"renderARIAInvalid",
"(",
"FacesContext",
"context",
",",
"UIInput",
"component",
")",
"throws",
"IOException",
"{",
"if",
"(",
"!",
"component",
".",
"isValid",
"(",
")",
")",
"{",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"writeAttribute",
"(",
"HTML",
".",
"ARIA_INVALID",
",",
"\"true\"",
",",
"null",
")",
";",
"}",
"}"
] |
Adds "aria-invalid" if the component is invalid.
@param context the {@link FacesContext}
@param component the {@link UIInput} component to add attributes for
@throws IOException if any error occurs writing the response
|
[
"Adds",
"aria",
"-",
"invalid",
"if",
"the",
"component",
"is",
"invalid",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/renderkit/InputRenderer.java#L95-L100
|
22,158
|
primefaces/primefaces
|
src/main/java/org/primefaces/renderkit/InputRenderer.java
|
InputRenderer.renderARIACombobox
|
protected void renderARIACombobox(FacesContext context, UIInput component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute("role", "combobox", null);
writer.writeAttribute(HTML.ARIA_HASPOPUP, "true", null);
writer.writeAttribute(HTML.ARIA_EXPANDED, "false", null);
}
|
java
|
protected void renderARIACombobox(FacesContext context, UIInput component) throws IOException {
ResponseWriter writer = context.getResponseWriter();
writer.writeAttribute("role", "combobox", null);
writer.writeAttribute(HTML.ARIA_HASPOPUP, "true", null);
writer.writeAttribute(HTML.ARIA_EXPANDED, "false", null);
}
|
[
"protected",
"void",
"renderARIACombobox",
"(",
"FacesContext",
"context",
",",
"UIInput",
"component",
")",
"throws",
"IOException",
"{",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"writeAttribute",
"(",
"\"role\"",
",",
"\"combobox\"",
",",
"null",
")",
";",
"writer",
".",
"writeAttribute",
"(",
"HTML",
".",
"ARIA_HASPOPUP",
",",
"\"true\"",
",",
"null",
")",
";",
"writer",
".",
"writeAttribute",
"(",
"HTML",
".",
"ARIA_EXPANDED",
",",
"\"false\"",
",",
"null",
")",
";",
"}"
] |
Adds ARIA attributes if the component is "role=combobox".
@param context the {@link FacesContext}
@param component the {@link UIInput} component to add attributes for
@throws IOException if any error occurs writing the response
@see https://www.w3.org/TR/wai-aria-practices/#combobox
|
[
"Adds",
"ARIA",
"attributes",
"if",
"the",
"component",
"is",
"role",
"=",
"combobox",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/renderkit/InputRenderer.java#L153-L158
|
22,159
|
primefaces/primefaces
|
src/main/java/org/primefaces/PrimeFaces.java
|
PrimeFaces.focus
|
public void focus(String expression, UIComponent base) {
if (LangUtils.isValueBlank(expression)) {
return;
}
FacesContext facesContext = getFacesContext();
String clientId = SearchExpressionFacade.resolveClientId(facesContext,
base,
expression);
executeScript("PrimeFaces.focus('" + clientId + "');");
}
|
java
|
public void focus(String expression, UIComponent base) {
if (LangUtils.isValueBlank(expression)) {
return;
}
FacesContext facesContext = getFacesContext();
String clientId = SearchExpressionFacade.resolveClientId(facesContext,
base,
expression);
executeScript("PrimeFaces.focus('" + clientId + "');");
}
|
[
"public",
"void",
"focus",
"(",
"String",
"expression",
",",
"UIComponent",
"base",
")",
"{",
"if",
"(",
"LangUtils",
".",
"isValueBlank",
"(",
"expression",
")",
")",
"{",
"return",
";",
"}",
"FacesContext",
"facesContext",
"=",
"getFacesContext",
"(",
")",
";",
"String",
"clientId",
"=",
"SearchExpressionFacade",
".",
"resolveClientId",
"(",
"facesContext",
",",
"base",
",",
"expression",
")",
";",
"executeScript",
"(",
"\"PrimeFaces.focus('\"",
"+",
"clientId",
"+",
"\"');\"",
")",
";",
"}"
] |
Resolves the search expression and focus the resolved component.
@param expression the search expression.
@param base the base component from which we will start to resolve the search expression.
|
[
"Resolves",
"the",
"search",
"expression",
"and",
"focus",
"the",
"resolved",
"component",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/PrimeFaces.java#L128-L139
|
22,160
|
primefaces/primefaces
|
src/main/java/org/primefaces/PrimeFaces.java
|
PrimeFaces.clearTableState
|
public void clearTableState(String key) {
Map<String, Object> sessionMap = getFacesContext().getExternalContext().getSessionMap();
Map<String, TableState> dtState = (Map) sessionMap.get(Constants.TABLE_STATE);
if (dtState != null) {
dtState.remove(key);
}
}
|
java
|
public void clearTableState(String key) {
Map<String, Object> sessionMap = getFacesContext().getExternalContext().getSessionMap();
Map<String, TableState> dtState = (Map) sessionMap.get(Constants.TABLE_STATE);
if (dtState != null) {
dtState.remove(key);
}
}
|
[
"public",
"void",
"clearTableState",
"(",
"String",
"key",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"sessionMap",
"=",
"getFacesContext",
"(",
")",
".",
"getExternalContext",
"(",
")",
".",
"getSessionMap",
"(",
")",
";",
"Map",
"<",
"String",
",",
"TableState",
">",
"dtState",
"=",
"(",
"Map",
")",
"sessionMap",
".",
"get",
"(",
"Constants",
".",
"TABLE_STATE",
")",
";",
"if",
"(",
"dtState",
"!=",
"null",
")",
"{",
"dtState",
".",
"remove",
"(",
"key",
")",
";",
"}",
"}"
] |
Removes the multiViewState for one specific DataTable within the current session.
@param key Key of the DataTable. See {@link org.primefaces.component.datatable.DataTable#getTableState(boolean)} for the namebuild of this key.
|
[
"Removes",
"the",
"multiViewState",
"for",
"one",
"specific",
"DataTable",
"within",
"the",
"current",
"session",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/PrimeFaces.java#L188-L194
|
22,161
|
primefaces/primefaces
|
src/main/java/org/primefaces/PrimeFaces.java
|
PrimeFaces.clearDataListState
|
public void clearDataListState(String key) {
Map<String, Object> sessionMap = getFacesContext().getExternalContext().getSessionMap();
Map<String, TableState> dtState = (Map) sessionMap.get(Constants.DATALIST_STATE);
if (dtState != null) {
dtState.remove(key);
}
}
|
java
|
public void clearDataListState(String key) {
Map<String, Object> sessionMap = getFacesContext().getExternalContext().getSessionMap();
Map<String, TableState> dtState = (Map) sessionMap.get(Constants.DATALIST_STATE);
if (dtState != null) {
dtState.remove(key);
}
}
|
[
"public",
"void",
"clearDataListState",
"(",
"String",
"key",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"sessionMap",
"=",
"getFacesContext",
"(",
")",
".",
"getExternalContext",
"(",
")",
".",
"getSessionMap",
"(",
")",
";",
"Map",
"<",
"String",
",",
"TableState",
">",
"dtState",
"=",
"(",
"Map",
")",
"sessionMap",
".",
"get",
"(",
"Constants",
".",
"DATALIST_STATE",
")",
";",
"if",
"(",
"dtState",
"!=",
"null",
")",
"{",
"dtState",
".",
"remove",
"(",
"key",
")",
";",
"}",
"}"
] |
Removes the multiViewState for one specific DataList within the current session.
@param key Key of the DataList. See {@link org.primefaces.component.datalist.DataList#getDataListState(boolean)}} for the namebuild of this key.
|
[
"Removes",
"the",
"multiViewState",
"for",
"one",
"specific",
"DataList",
"within",
"the",
"current",
"session",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/PrimeFaces.java#L207-L213
|
22,162
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/optionconfig/tooltip/Tooltip.java
|
Tooltip.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "enabled", this.enabled, false);
ChartUtils.writeDataValue(fsw, "mode", this.mode, true);
ChartUtils.writeDataValue(fsw, "intersect", this.intersect, true);
ChartUtils.writeDataValue(fsw, "position", this.position, true);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "titleFontFamily", this.titleFontFamily, true);
ChartUtils.writeDataValue(fsw, "titleFontSize", this.titleFontSize, true);
ChartUtils.writeDataValue(fsw, "titleFontStyle", this.titleFontStyle, true);
ChartUtils.writeDataValue(fsw, "titleFontColor", this.titleFontColor, true);
ChartUtils.writeDataValue(fsw, "titleSpacing", this.titleSpacing, true);
ChartUtils.writeDataValue(fsw, "titleMarginBottom", this.titleMarginBottom, true);
ChartUtils.writeDataValue(fsw, "bodyFontFamily", this.bodyFontFamily, true);
ChartUtils.writeDataValue(fsw, "bodyFontSize", this.bodyFontSize, true);
ChartUtils.writeDataValue(fsw, "bodyFontStyle", this.bodyFontStyle, true);
ChartUtils.writeDataValue(fsw, "bodyFontColor", this.bodyFontColor, true);
ChartUtils.writeDataValue(fsw, "bodySpacing", this.bodySpacing, true);
ChartUtils.writeDataValue(fsw, "footerFontFamily", this.footerFontFamily, true);
ChartUtils.writeDataValue(fsw, "footerFontSize", this.footerFontSize, true);
ChartUtils.writeDataValue(fsw, "footerFontStyle", this.footerFontStyle, true);
ChartUtils.writeDataValue(fsw, "footerFontColor", this.footerFontColor, true);
ChartUtils.writeDataValue(fsw, "footerSpacing", this.footerSpacing, true);
ChartUtils.writeDataValue(fsw, "footerMarginTop", this.footerMarginTop, true);
ChartUtils.writeDataValue(fsw, "xPadding", this.xpadding, true);
ChartUtils.writeDataValue(fsw, "yPadding", this.ypadding, true);
ChartUtils.writeDataValue(fsw, "caretPadding", this.caretPadding, true);
ChartUtils.writeDataValue(fsw, "caretSize", this.caretSize, true);
ChartUtils.writeDataValue(fsw, "cornerRadius", this.cornerRadius, true);
ChartUtils.writeDataValue(fsw, "multiKeyBackground", this.multiKeyBackground, true);
ChartUtils.writeDataValue(fsw, "displayColors", this.displayColors, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "enabled", this.enabled, false);
ChartUtils.writeDataValue(fsw, "mode", this.mode, true);
ChartUtils.writeDataValue(fsw, "intersect", this.intersect, true);
ChartUtils.writeDataValue(fsw, "position", this.position, true);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "titleFontFamily", this.titleFontFamily, true);
ChartUtils.writeDataValue(fsw, "titleFontSize", this.titleFontSize, true);
ChartUtils.writeDataValue(fsw, "titleFontStyle", this.titleFontStyle, true);
ChartUtils.writeDataValue(fsw, "titleFontColor", this.titleFontColor, true);
ChartUtils.writeDataValue(fsw, "titleSpacing", this.titleSpacing, true);
ChartUtils.writeDataValue(fsw, "titleMarginBottom", this.titleMarginBottom, true);
ChartUtils.writeDataValue(fsw, "bodyFontFamily", this.bodyFontFamily, true);
ChartUtils.writeDataValue(fsw, "bodyFontSize", this.bodyFontSize, true);
ChartUtils.writeDataValue(fsw, "bodyFontStyle", this.bodyFontStyle, true);
ChartUtils.writeDataValue(fsw, "bodyFontColor", this.bodyFontColor, true);
ChartUtils.writeDataValue(fsw, "bodySpacing", this.bodySpacing, true);
ChartUtils.writeDataValue(fsw, "footerFontFamily", this.footerFontFamily, true);
ChartUtils.writeDataValue(fsw, "footerFontSize", this.footerFontSize, true);
ChartUtils.writeDataValue(fsw, "footerFontStyle", this.footerFontStyle, true);
ChartUtils.writeDataValue(fsw, "footerFontColor", this.footerFontColor, true);
ChartUtils.writeDataValue(fsw, "footerSpacing", this.footerSpacing, true);
ChartUtils.writeDataValue(fsw, "footerMarginTop", this.footerMarginTop, true);
ChartUtils.writeDataValue(fsw, "xPadding", this.xpadding, true);
ChartUtils.writeDataValue(fsw, "yPadding", this.ypadding, true);
ChartUtils.writeDataValue(fsw, "caretPadding", this.caretPadding, true);
ChartUtils.writeDataValue(fsw, "caretSize", this.caretSize, true);
ChartUtils.writeDataValue(fsw, "cornerRadius", this.cornerRadius, true);
ChartUtils.writeDataValue(fsw, "multiKeyBackground", this.multiKeyBackground, true);
ChartUtils.writeDataValue(fsw, "displayColors", this.displayColors, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"enabled\"",
",",
"this",
".",
"enabled",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"mode\"",
",",
"this",
".",
"mode",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"intersect\"",
",",
"this",
".",
"intersect",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"position\"",
",",
"this",
".",
"position",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backgroundColor\"",
",",
"this",
".",
"backgroundColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleFontFamily\"",
",",
"this",
".",
"titleFontFamily",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleFontSize\"",
",",
"this",
".",
"titleFontSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleFontStyle\"",
",",
"this",
".",
"titleFontStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleFontColor\"",
",",
"this",
".",
"titleFontColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleSpacing\"",
",",
"this",
".",
"titleSpacing",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"titleMarginBottom\"",
",",
"this",
".",
"titleMarginBottom",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"bodyFontFamily\"",
",",
"this",
".",
"bodyFontFamily",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"bodyFontSize\"",
",",
"this",
".",
"bodyFontSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"bodyFontStyle\"",
",",
"this",
".",
"bodyFontStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"bodyFontColor\"",
",",
"this",
".",
"bodyFontColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"bodySpacing\"",
",",
"this",
".",
"bodySpacing",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerFontFamily\"",
",",
"this",
".",
"footerFontFamily",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerFontSize\"",
",",
"this",
".",
"footerFontSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerFontStyle\"",
",",
"this",
".",
"footerFontStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerFontColor\"",
",",
"this",
".",
"footerFontColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerSpacing\"",
",",
"this",
".",
"footerSpacing",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"footerMarginTop\"",
",",
"this",
".",
"footerMarginTop",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"xPadding\"",
",",
"this",
".",
"xpadding",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"yPadding\"",
",",
"this",
".",
"ypadding",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"caretPadding\"",
",",
"this",
".",
"caretPadding",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"caretSize\"",
",",
"this",
".",
"caretSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"cornerRadius\"",
",",
"this",
".",
"cornerRadius",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"multiKeyBackground\"",
",",
"this",
".",
"multiKeyBackground",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"displayColors\"",
",",
"this",
".",
"displayColors",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderColor\"",
",",
"this",
".",
"borderColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderWidth\"",
",",
"this",
".",
"borderWidth",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of Tooltip
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"Tooltip"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/optionconfig/tooltip/Tooltip.java#L636-L677
|
22,163
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ComponentUtils.java
|
ComponentUtils.getConverter
|
public static Converter getConverter(FacesContext context, UIComponent component) {
if (!(component instanceof ValueHolder)) {
return null;
}
Converter converter = ((ValueHolder) component).getConverter();
if (converter != null) {
return converter;
}
ValueExpression valueExpression = component.getValueExpression("value");
if (valueExpression == null) {
return null;
}
Class<?> converterType = valueExpression.getType(context.getELContext());
if (converterType == null || converterType == Object.class) {
// no conversion is needed
return null;
}
if (converterType == String.class
&& !PrimeApplicationContext.getCurrentInstance(context).getConfig().isStringConverterAvailable()) {
return null;
}
return context.getApplication().createConverter(converterType);
}
|
java
|
public static Converter getConverter(FacesContext context, UIComponent component) {
if (!(component instanceof ValueHolder)) {
return null;
}
Converter converter = ((ValueHolder) component).getConverter();
if (converter != null) {
return converter;
}
ValueExpression valueExpression = component.getValueExpression("value");
if (valueExpression == null) {
return null;
}
Class<?> converterType = valueExpression.getType(context.getELContext());
if (converterType == null || converterType == Object.class) {
// no conversion is needed
return null;
}
if (converterType == String.class
&& !PrimeApplicationContext.getCurrentInstance(context).getConfig().isStringConverterAvailable()) {
return null;
}
return context.getApplication().createConverter(converterType);
}
|
[
"public",
"static",
"Converter",
"getConverter",
"(",
"FacesContext",
"context",
",",
"UIComponent",
"component",
")",
"{",
"if",
"(",
"!",
"(",
"component",
"instanceof",
"ValueHolder",
")",
")",
"{",
"return",
"null",
";",
"}",
"Converter",
"converter",
"=",
"(",
"(",
"ValueHolder",
")",
"component",
")",
".",
"getConverter",
"(",
")",
";",
"if",
"(",
"converter",
"!=",
"null",
")",
"{",
"return",
"converter",
";",
"}",
"ValueExpression",
"valueExpression",
"=",
"component",
".",
"getValueExpression",
"(",
"\"value\"",
")",
";",
"if",
"(",
"valueExpression",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"Class",
"<",
"?",
">",
"converterType",
"=",
"valueExpression",
".",
"getType",
"(",
"context",
".",
"getELContext",
"(",
")",
")",
";",
"if",
"(",
"converterType",
"==",
"null",
"||",
"converterType",
"==",
"Object",
".",
"class",
")",
"{",
"// no conversion is needed",
"return",
"null",
";",
"}",
"if",
"(",
"converterType",
"==",
"String",
".",
"class",
"&&",
"!",
"PrimeApplicationContext",
".",
"getCurrentInstance",
"(",
"context",
")",
".",
"getConfig",
"(",
")",
".",
"isStringConverterAvailable",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"context",
".",
"getApplication",
"(",
")",
".",
"createConverter",
"(",
"converterType",
")",
";",
"}"
] |
Finds appropriate converter for a given value holder
@param context FacesContext instance
@param component ValueHolder instance to look converter for
@return Converter
|
[
"Finds",
"appropriate",
"converter",
"for",
"a",
"given",
"value",
"holder"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ComponentUtils.java#L139-L166
|
22,164
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ComponentUtils.java
|
ComponentUtils.calculateViewId
|
public static String calculateViewId(FacesContext context) {
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
String viewId = (String) requestMap.get("javax.servlet.include.path_info");
if (viewId == null) {
viewId = context.getExternalContext().getRequestPathInfo();
}
if (viewId == null) {
viewId = (String) requestMap.get("javax.servlet.include.servlet_path");
}
if (viewId == null) {
viewId = context.getExternalContext().getRequestServletPath();
}
return viewId;
}
|
java
|
public static String calculateViewId(FacesContext context) {
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
String viewId = (String) requestMap.get("javax.servlet.include.path_info");
if (viewId == null) {
viewId = context.getExternalContext().getRequestPathInfo();
}
if (viewId == null) {
viewId = (String) requestMap.get("javax.servlet.include.servlet_path");
}
if (viewId == null) {
viewId = context.getExternalContext().getRequestServletPath();
}
return viewId;
}
|
[
"public",
"static",
"String",
"calculateViewId",
"(",
"FacesContext",
"context",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"requestMap",
"=",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getRequestMap",
"(",
")",
";",
"String",
"viewId",
"=",
"(",
"String",
")",
"requestMap",
".",
"get",
"(",
"\"javax.servlet.include.path_info\"",
")",
";",
"if",
"(",
"viewId",
"==",
"null",
")",
"{",
"viewId",
"=",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getRequestPathInfo",
"(",
")",
";",
"}",
"if",
"(",
"viewId",
"==",
"null",
")",
"{",
"viewId",
"=",
"(",
"String",
")",
"requestMap",
".",
"get",
"(",
"\"javax.servlet.include.servlet_path\"",
")",
";",
"}",
"if",
"(",
"viewId",
"==",
"null",
")",
"{",
"viewId",
"=",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getRequestServletPath",
"(",
")",
";",
"}",
"return",
"viewId",
";",
"}"
] |
Calculates the current viewId - we can't get it from the ViewRoot if it's not available.
@param context The {@link FacesContext}.
@return The current viewId.
|
[
"Calculates",
"the",
"current",
"viewId",
"-",
"we",
"can",
"t",
"get",
"it",
"from",
"the",
"ViewRoot",
"if",
"it",
"s",
"not",
"available",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ComponentUtils.java#L458-L475
|
22,165
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ComponentUtils.java
|
ComponentUtils.shouldRenderFacet
|
public static boolean shouldRenderFacet(UIComponent facet) {
if (facet == null || !facet.isRendered()) {
// For any future version of JSF where the f:facet gets a rendered attribute (https://github.com/javaserverfaces/mojarra/issues/4299)
// or there is only 1 child.
return false;
}
// Facet has no child but is rendered
if (facet.getChildren().isEmpty()) {
return true;
}
return shouldRenderChildren(facet);
}
|
java
|
public static boolean shouldRenderFacet(UIComponent facet) {
if (facet == null || !facet.isRendered()) {
// For any future version of JSF where the f:facet gets a rendered attribute (https://github.com/javaserverfaces/mojarra/issues/4299)
// or there is only 1 child.
return false;
}
// Facet has no child but is rendered
if (facet.getChildren().isEmpty()) {
return true;
}
return shouldRenderChildren(facet);
}
|
[
"public",
"static",
"boolean",
"shouldRenderFacet",
"(",
"UIComponent",
"facet",
")",
"{",
"if",
"(",
"facet",
"==",
"null",
"||",
"!",
"facet",
".",
"isRendered",
"(",
")",
")",
"{",
"// For any future version of JSF where the f:facet gets a rendered attribute (https://github.com/javaserverfaces/mojarra/issues/4299)",
"// or there is only 1 child.",
"return",
"false",
";",
"}",
"// Facet has no child but is rendered",
"if",
"(",
"facet",
".",
"getChildren",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"shouldRenderChildren",
"(",
"facet",
")",
";",
"}"
] |
Checks if the facet and one of the first level child's is rendered.
@param facet The Facet component to check
@return true when facet and one of the first level child's is rendered.
|
[
"Checks",
"if",
"the",
"facet",
"and",
"one",
"of",
"the",
"first",
"level",
"child",
"s",
"is",
"rendered",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ComponentUtils.java#L528-L541
|
22,166
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ComponentUtils.java
|
ComponentUtils.shouldRenderChildren
|
public static boolean shouldRenderChildren(UIComponent component) {
for (int i = 0; i < component.getChildren().size(); i++) {
if (component.getChildren().get(i).isRendered()) {
return true;
}
}
return false;
}
|
java
|
public static boolean shouldRenderChildren(UIComponent component) {
for (int i = 0; i < component.getChildren().size(); i++) {
if (component.getChildren().get(i).isRendered()) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"boolean",
"shouldRenderChildren",
"(",
"UIComponent",
"component",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"component",
".",
"getChildren",
"(",
")",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"component",
".",
"getChildren",
"(",
")",
".",
"get",
"(",
"i",
")",
".",
"isRendered",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Checks if the component's children are rendered
@param component The component to check
@return true if one of the first level child's is rendered.
|
[
"Checks",
"if",
"the",
"component",
"s",
"children",
"are",
"rendered"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ComponentUtils.java#L548-L556
|
22,167
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/api/UIData.java
|
UIData.setRowIndexRowStatePreserved
|
private void setRowIndexRowStatePreserved(int rowIndex) {
if (rowIndex < -1) {
throw new IllegalArgumentException("rowIndex is less than -1");
}
if (getRowIndex() == rowIndex) {
return;
}
FacesContext facesContext = getFacesContext();
if (_initialDescendantFullComponentState != null) {
//Just save the row
Map<String, Object> sm = saveFullDescendantComponentStates(facesContext, null, getChildren().iterator(), false);
if (sm != null && !sm.isEmpty()) {
_rowDeltaStates.put(getContainerClientId(facesContext), sm);
}
if (getRowIndex() != -1) {
_rowTransientStates.put(getContainerClientId(facesContext),
saveTransientDescendantComponentStates(facesContext, null, getChildren().iterator(), false));
}
}
// Update to the new row index
//this.rowIndex = rowIndex;
getStateHelper().put(PropertyKeys.rowIndex, rowIndex);
DataModel localModel = getDataModel();
localModel.setRowIndex(rowIndex);
// if rowIndex is -1, clear the cache
if (rowIndex == -1) {
setDataModel(null);
}
// Clear or expose the current row data as a request scope attribute
String var = getVar();
if (var != null) {
Map<String, Object> requestMap
= getFacesContext().getExternalContext().getRequestMap();
if (rowIndex == -1) {
oldVar = requestMap.remove(var);
}
else if (isRowAvailable()) {
requestMap.put(var, getRowData());
}
else {
requestMap.remove(var);
if (null != oldVar) {
requestMap.put(var, oldVar);
oldVar = null;
}
}
}
if (_initialDescendantFullComponentState != null) {
Object rowState = _rowDeltaStates.get(getContainerClientId(facesContext));
if (rowState == null) {
//Restore as original
restoreFullDescendantComponentStates(facesContext, getChildren().iterator(), _initialDescendantFullComponentState, false);
}
else {
//Restore first original and then delta
restoreFullDescendantComponentDeltaStates(facesContext, getChildren().iterator(), rowState, _initialDescendantFullComponentState, false);
}
if (getRowIndex() == -1) {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), null, false);
}
else {
rowState = _rowTransientStates.get(getContainerClientId(facesContext));
if (rowState == null) {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), null, false);
}
else {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), (Map<String, Object>) rowState, false);
}
}
}
}
|
java
|
private void setRowIndexRowStatePreserved(int rowIndex) {
if (rowIndex < -1) {
throw new IllegalArgumentException("rowIndex is less than -1");
}
if (getRowIndex() == rowIndex) {
return;
}
FacesContext facesContext = getFacesContext();
if (_initialDescendantFullComponentState != null) {
//Just save the row
Map<String, Object> sm = saveFullDescendantComponentStates(facesContext, null, getChildren().iterator(), false);
if (sm != null && !sm.isEmpty()) {
_rowDeltaStates.put(getContainerClientId(facesContext), sm);
}
if (getRowIndex() != -1) {
_rowTransientStates.put(getContainerClientId(facesContext),
saveTransientDescendantComponentStates(facesContext, null, getChildren().iterator(), false));
}
}
// Update to the new row index
//this.rowIndex = rowIndex;
getStateHelper().put(PropertyKeys.rowIndex, rowIndex);
DataModel localModel = getDataModel();
localModel.setRowIndex(rowIndex);
// if rowIndex is -1, clear the cache
if (rowIndex == -1) {
setDataModel(null);
}
// Clear or expose the current row data as a request scope attribute
String var = getVar();
if (var != null) {
Map<String, Object> requestMap
= getFacesContext().getExternalContext().getRequestMap();
if (rowIndex == -1) {
oldVar = requestMap.remove(var);
}
else if (isRowAvailable()) {
requestMap.put(var, getRowData());
}
else {
requestMap.remove(var);
if (null != oldVar) {
requestMap.put(var, oldVar);
oldVar = null;
}
}
}
if (_initialDescendantFullComponentState != null) {
Object rowState = _rowDeltaStates.get(getContainerClientId(facesContext));
if (rowState == null) {
//Restore as original
restoreFullDescendantComponentStates(facesContext, getChildren().iterator(), _initialDescendantFullComponentState, false);
}
else {
//Restore first original and then delta
restoreFullDescendantComponentDeltaStates(facesContext, getChildren().iterator(), rowState, _initialDescendantFullComponentState, false);
}
if (getRowIndex() == -1) {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), null, false);
}
else {
rowState = _rowTransientStates.get(getContainerClientId(facesContext));
if (rowState == null) {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), null, false);
}
else {
restoreTransientDescendantComponentStates(facesContext, getChildren().iterator(), (Map<String, Object>) rowState, false);
}
}
}
}
|
[
"private",
"void",
"setRowIndexRowStatePreserved",
"(",
"int",
"rowIndex",
")",
"{",
"if",
"(",
"rowIndex",
"<",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"rowIndex is less than -1\"",
")",
";",
"}",
"if",
"(",
"getRowIndex",
"(",
")",
"==",
"rowIndex",
")",
"{",
"return",
";",
"}",
"FacesContext",
"facesContext",
"=",
"getFacesContext",
"(",
")",
";",
"if",
"(",
"_initialDescendantFullComponentState",
"!=",
"null",
")",
"{",
"//Just save the row",
"Map",
"<",
"String",
",",
"Object",
">",
"sm",
"=",
"saveFullDescendantComponentStates",
"(",
"facesContext",
",",
"null",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"false",
")",
";",
"if",
"(",
"sm",
"!=",
"null",
"&&",
"!",
"sm",
".",
"isEmpty",
"(",
")",
")",
"{",
"_rowDeltaStates",
".",
"put",
"(",
"getContainerClientId",
"(",
"facesContext",
")",
",",
"sm",
")",
";",
"}",
"if",
"(",
"getRowIndex",
"(",
")",
"!=",
"-",
"1",
")",
"{",
"_rowTransientStates",
".",
"put",
"(",
"getContainerClientId",
"(",
"facesContext",
")",
",",
"saveTransientDescendantComponentStates",
"(",
"facesContext",
",",
"null",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"false",
")",
")",
";",
"}",
"}",
"// Update to the new row index",
"//this.rowIndex = rowIndex;",
"getStateHelper",
"(",
")",
".",
"put",
"(",
"PropertyKeys",
".",
"rowIndex",
",",
"rowIndex",
")",
";",
"DataModel",
"localModel",
"=",
"getDataModel",
"(",
")",
";",
"localModel",
".",
"setRowIndex",
"(",
"rowIndex",
")",
";",
"// if rowIndex is -1, clear the cache",
"if",
"(",
"rowIndex",
"==",
"-",
"1",
")",
"{",
"setDataModel",
"(",
"null",
")",
";",
"}",
"// Clear or expose the current row data as a request scope attribute",
"String",
"var",
"=",
"getVar",
"(",
")",
";",
"if",
"(",
"var",
"!=",
"null",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"requestMap",
"=",
"getFacesContext",
"(",
")",
".",
"getExternalContext",
"(",
")",
".",
"getRequestMap",
"(",
")",
";",
"if",
"(",
"rowIndex",
"==",
"-",
"1",
")",
"{",
"oldVar",
"=",
"requestMap",
".",
"remove",
"(",
"var",
")",
";",
"}",
"else",
"if",
"(",
"isRowAvailable",
"(",
")",
")",
"{",
"requestMap",
".",
"put",
"(",
"var",
",",
"getRowData",
"(",
")",
")",
";",
"}",
"else",
"{",
"requestMap",
".",
"remove",
"(",
"var",
")",
";",
"if",
"(",
"null",
"!=",
"oldVar",
")",
"{",
"requestMap",
".",
"put",
"(",
"var",
",",
"oldVar",
")",
";",
"oldVar",
"=",
"null",
";",
"}",
"}",
"}",
"if",
"(",
"_initialDescendantFullComponentState",
"!=",
"null",
")",
"{",
"Object",
"rowState",
"=",
"_rowDeltaStates",
".",
"get",
"(",
"getContainerClientId",
"(",
"facesContext",
")",
")",
";",
"if",
"(",
"rowState",
"==",
"null",
")",
"{",
"//Restore as original",
"restoreFullDescendantComponentStates",
"(",
"facesContext",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"_initialDescendantFullComponentState",
",",
"false",
")",
";",
"}",
"else",
"{",
"//Restore first original and then delta",
"restoreFullDescendantComponentDeltaStates",
"(",
"facesContext",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"rowState",
",",
"_initialDescendantFullComponentState",
",",
"false",
")",
";",
"}",
"if",
"(",
"getRowIndex",
"(",
")",
"==",
"-",
"1",
")",
"{",
"restoreTransientDescendantComponentStates",
"(",
"facesContext",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"null",
",",
"false",
")",
";",
"}",
"else",
"{",
"rowState",
"=",
"_rowTransientStates",
".",
"get",
"(",
"getContainerClientId",
"(",
"facesContext",
")",
")",
";",
"if",
"(",
"rowState",
"==",
"null",
")",
"{",
"restoreTransientDescendantComponentStates",
"(",
"facesContext",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"null",
",",
"false",
")",
";",
"}",
"else",
"{",
"restoreTransientDescendantComponentStates",
"(",
"facesContext",
",",
"getChildren",
"(",
")",
".",
"iterator",
"(",
")",
",",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
")",
"rowState",
",",
"false",
")",
";",
"}",
"}",
"}",
"}"
] |
Row State preserved implementation is taken from Mojarra
|
[
"Row",
"State",
"preserved",
"implementation",
"is",
"taken",
"from",
"Mojarra"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/api/UIData.java#L498-L576
|
22,168
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/TreeUtils.java
|
TreeUtils.sortNode
|
public static void sortNode(TreeNode node, Comparator comparator) {
TreeNodeList children = (TreeNodeList) node.getChildren();
if (children != null && !children.isEmpty()) {
Object[] childrenArray = children.toArray();
Arrays.sort(childrenArray, comparator);
for (int i = 0; i < childrenArray.length; i++) {
children.setSibling(i, (TreeNode) childrenArray[i]);
}
for (int i = 0; i < children.size(); i++) {
sortNode(children.get(i), comparator);
}
}
}
|
java
|
public static void sortNode(TreeNode node, Comparator comparator) {
TreeNodeList children = (TreeNodeList) node.getChildren();
if (children != null && !children.isEmpty()) {
Object[] childrenArray = children.toArray();
Arrays.sort(childrenArray, comparator);
for (int i = 0; i < childrenArray.length; i++) {
children.setSibling(i, (TreeNode) childrenArray[i]);
}
for (int i = 0; i < children.size(); i++) {
sortNode(children.get(i), comparator);
}
}
}
|
[
"public",
"static",
"void",
"sortNode",
"(",
"TreeNode",
"node",
",",
"Comparator",
"comparator",
")",
"{",
"TreeNodeList",
"children",
"=",
"(",
"TreeNodeList",
")",
"node",
".",
"getChildren",
"(",
")",
";",
"if",
"(",
"children",
"!=",
"null",
"&&",
"!",
"children",
".",
"isEmpty",
"(",
")",
")",
"{",
"Object",
"[",
"]",
"childrenArray",
"=",
"children",
".",
"toArray",
"(",
")",
";",
"Arrays",
".",
"sort",
"(",
"childrenArray",
",",
"comparator",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"childrenArray",
".",
"length",
";",
"i",
"++",
")",
"{",
"children",
".",
"setSibling",
"(",
"i",
",",
"(",
"TreeNode",
")",
"childrenArray",
"[",
"i",
"]",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"sortNode",
"(",
"children",
".",
"get",
"(",
"i",
")",
",",
"comparator",
")",
";",
"}",
"}",
"}"
] |
Sorts children of a node using a comparator
@param node Node instance whose children to be sorted
@param comparator Comparator to use in sorting
|
[
"Sorts",
"children",
"of",
"a",
"node",
"using",
"a",
"comparator"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/TreeUtils.java#L45-L59
|
22,169
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/ComponentTraversalUtils.java
|
ComponentTraversalUtils.firstById
|
public static void firstById(String id, UIComponent base, char separatorChar, FacesContext context, ContextCallback callback) {
// try #findComponent first
UIComponent component = base.findComponent(id);
// try #invokeOnComponent
// it's required to support e.g. a full client id for a component which is placed inside UIData components
if (component == null) {
// #invokeOnComponent doesn't support the leading seperator char
String tempExpression = id;
if (tempExpression.charAt(0) == separatorChar) {
tempExpression = tempExpression.substring(1);
}
context.getViewRoot().invokeOnComponent(context, tempExpression, callback);
}
else {
callback.invokeContextCallback(context, component);
}
}
|
java
|
public static void firstById(String id, UIComponent base, char separatorChar, FacesContext context, ContextCallback callback) {
// try #findComponent first
UIComponent component = base.findComponent(id);
// try #invokeOnComponent
// it's required to support e.g. a full client id for a component which is placed inside UIData components
if (component == null) {
// #invokeOnComponent doesn't support the leading seperator char
String tempExpression = id;
if (tempExpression.charAt(0) == separatorChar) {
tempExpression = tempExpression.substring(1);
}
context.getViewRoot().invokeOnComponent(context, tempExpression, callback);
}
else {
callback.invokeContextCallback(context, component);
}
}
|
[
"public",
"static",
"void",
"firstById",
"(",
"String",
"id",
",",
"UIComponent",
"base",
",",
"char",
"separatorChar",
",",
"FacesContext",
"context",
",",
"ContextCallback",
"callback",
")",
"{",
"// try #findComponent first",
"UIComponent",
"component",
"=",
"base",
".",
"findComponent",
"(",
"id",
")",
";",
"// try #invokeOnComponent",
"// it's required to support e.g. a full client id for a component which is placed inside UIData components",
"if",
"(",
"component",
"==",
"null",
")",
"{",
"// #invokeOnComponent doesn't support the leading seperator char",
"String",
"tempExpression",
"=",
"id",
";",
"if",
"(",
"tempExpression",
".",
"charAt",
"(",
"0",
")",
"==",
"separatorChar",
")",
"{",
"tempExpression",
"=",
"tempExpression",
".",
"substring",
"(",
"1",
")",
";",
"}",
"context",
".",
"getViewRoot",
"(",
")",
".",
"invokeOnComponent",
"(",
"context",
",",
"tempExpression",
",",
"callback",
")",
";",
"}",
"else",
"{",
"callback",
".",
"invokeContextCallback",
"(",
"context",
",",
"component",
")",
";",
"}",
"}"
] |
Finds the first component by the given id expression or client id.
@param id The id.
@param base The base component to start the traversal.
@param separatorChar The separatorChar (e.g. :).
@param context The FacesContext.
@param callback the callback for the found component
|
[
"Finds",
"the",
"first",
"component",
"by",
"the",
"given",
"id",
"expression",
"or",
"client",
"id",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/ComponentTraversalUtils.java#L148-L167
|
22,170
|
primefaces/primefaces
|
src/main/java/org/primefaces/expression/SearchExpressionFacade.java
|
SearchExpressionFacade.split
|
public static String[] split(FacesContext context, String value, char... separators) {
if (LangUtils.isValueBlank(value)) {
return null;
}
List<String> tokens = new ArrayList<>(5);
StringBuilder buffer = SharedStringBuilder.get(context, SHARED_SPLIT_BUFFER_KEY);
int parenthesesCounter = 0;
int length = value.length();
for (int i = 0; i < length; i++) {
char c = value.charAt(i);
if (c == '(') {
parenthesesCounter++;
}
if (c == ')') {
parenthesesCounter--;
}
if (parenthesesCounter == 0) {
boolean isSeparator = false;
for (char separator : separators) {
if (c == separator) {
isSeparator = true;
}
}
if (isSeparator) {
// lets add token inside buffer to our tokens
tokens.add(buffer.toString());
// now we need to clear buffer
buffer.delete(0, buffer.length());
}
else {
buffer.append(c);
}
}
else {
buffer.append(c);
}
}
// lets not forget about part after the separator
tokens.add(buffer.toString());
return tokens.toArray(new String[tokens.size()]);
}
|
java
|
public static String[] split(FacesContext context, String value, char... separators) {
if (LangUtils.isValueBlank(value)) {
return null;
}
List<String> tokens = new ArrayList<>(5);
StringBuilder buffer = SharedStringBuilder.get(context, SHARED_SPLIT_BUFFER_KEY);
int parenthesesCounter = 0;
int length = value.length();
for (int i = 0; i < length; i++) {
char c = value.charAt(i);
if (c == '(') {
parenthesesCounter++;
}
if (c == ')') {
parenthesesCounter--;
}
if (parenthesesCounter == 0) {
boolean isSeparator = false;
for (char separator : separators) {
if (c == separator) {
isSeparator = true;
}
}
if (isSeparator) {
// lets add token inside buffer to our tokens
tokens.add(buffer.toString());
// now we need to clear buffer
buffer.delete(0, buffer.length());
}
else {
buffer.append(c);
}
}
else {
buffer.append(c);
}
}
// lets not forget about part after the separator
tokens.add(buffer.toString());
return tokens.toArray(new String[tokens.size()]);
}
|
[
"public",
"static",
"String",
"[",
"]",
"split",
"(",
"FacesContext",
"context",
",",
"String",
"value",
",",
"char",
"...",
"separators",
")",
"{",
"if",
"(",
"LangUtils",
".",
"isValueBlank",
"(",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"String",
">",
"tokens",
"=",
"new",
"ArrayList",
"<>",
"(",
"5",
")",
";",
"StringBuilder",
"buffer",
"=",
"SharedStringBuilder",
".",
"get",
"(",
"context",
",",
"SHARED_SPLIT_BUFFER_KEY",
")",
";",
"int",
"parenthesesCounter",
"=",
"0",
";",
"int",
"length",
"=",
"value",
".",
"length",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
")",
"{",
"char",
"c",
"=",
"value",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"parenthesesCounter",
"++",
";",
"}",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"parenthesesCounter",
"--",
";",
"}",
"if",
"(",
"parenthesesCounter",
"==",
"0",
")",
"{",
"boolean",
"isSeparator",
"=",
"false",
";",
"for",
"(",
"char",
"separator",
":",
"separators",
")",
"{",
"if",
"(",
"c",
"==",
"separator",
")",
"{",
"isSeparator",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"isSeparator",
")",
"{",
"// lets add token inside buffer to our tokens",
"tokens",
".",
"add",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"// now we need to clear buffer",
"buffer",
".",
"delete",
"(",
"0",
",",
"buffer",
".",
"length",
"(",
")",
")",
";",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"else",
"{",
"buffer",
".",
"append",
"(",
"c",
")",
";",
"}",
"}",
"// lets not forget about part after the separator",
"tokens",
".",
"add",
"(",
"buffer",
".",
"toString",
"(",
")",
")",
";",
"return",
"tokens",
".",
"toArray",
"(",
"new",
"String",
"[",
"tokens",
".",
"size",
"(",
")",
"]",
")",
";",
"}"
] |
Splits the given string by the given separator, but ignoring separators inside parentheses.
@param context The current {@link FacesContext}.
@param value The string value.
@param separators The separators.
@return The splitted string.
|
[
"Splits",
"the",
"given",
"string",
"by",
"the",
"given",
"separator",
"but",
"ignoring",
"separators",
"inside",
"parentheses",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/expression/SearchExpressionFacade.java#L809-L858
|
22,171
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/optionconfig/elements/Elements.java
|
Elements.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
boolean hasComma = false;
String preString;
try {
if (this.point != null) {
fsw.write("\"point\":{");
fsw.write(this.point.encode());
fsw.write("}");
hasComma = true;
}
if (this.line != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"line\":{");
fsw.write(this.line.encode());
fsw.write("}");
hasComma = true;
}
if (this.rectangle != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"rectangle\":{");
fsw.write(this.rectangle.encode());
fsw.write("}");
hasComma = true;
}
if (this.arc != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"arc\":{");
fsw.write(this.arc.encode());
fsw.write("}");
}
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
boolean hasComma = false;
String preString;
try {
if (this.point != null) {
fsw.write("\"point\":{");
fsw.write(this.point.encode());
fsw.write("}");
hasComma = true;
}
if (this.line != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"line\":{");
fsw.write(this.line.encode());
fsw.write("}");
hasComma = true;
}
if (this.rectangle != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"rectangle\":{");
fsw.write(this.rectangle.encode());
fsw.write("}");
hasComma = true;
}
if (this.arc != null) {
preString = hasComma ? "," : "";
fsw.write(preString + "\"arc\":{");
fsw.write(this.arc.encode());
fsw.write("}");
}
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"boolean",
"hasComma",
"=",
"false",
";",
"String",
"preString",
";",
"try",
"{",
"if",
"(",
"this",
".",
"point",
"!=",
"null",
")",
"{",
"fsw",
".",
"write",
"(",
"\"\\\"point\\\":{\"",
")",
";",
"fsw",
".",
"write",
"(",
"this",
".",
"point",
".",
"encode",
"(",
")",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"hasComma",
"=",
"true",
";",
"}",
"if",
"(",
"this",
".",
"line",
"!=",
"null",
")",
"{",
"preString",
"=",
"hasComma",
"?",
"\",\"",
":",
"\"\"",
";",
"fsw",
".",
"write",
"(",
"preString",
"+",
"\"\\\"line\\\":{\"",
")",
";",
"fsw",
".",
"write",
"(",
"this",
".",
"line",
".",
"encode",
"(",
")",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"hasComma",
"=",
"true",
";",
"}",
"if",
"(",
"this",
".",
"rectangle",
"!=",
"null",
")",
"{",
"preString",
"=",
"hasComma",
"?",
"\",\"",
":",
"\"\"",
";",
"fsw",
".",
"write",
"(",
"preString",
"+",
"\"\\\"rectangle\\\":{\"",
")",
";",
"fsw",
".",
"write",
"(",
"this",
".",
"rectangle",
".",
"encode",
"(",
")",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"hasComma",
"=",
"true",
";",
"}",
"if",
"(",
"this",
".",
"arc",
"!=",
"null",
")",
"{",
"preString",
"=",
"hasComma",
"?",
"\",\"",
":",
"\"\"",
";",
"fsw",
".",
"write",
"(",
"preString",
"+",
"\"\\\"arc\\\":{\"",
")",
";",
"fsw",
".",
"write",
"(",
"this",
".",
"arc",
".",
"encode",
"(",
")",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"}",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of Elements
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"Elements"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/optionconfig/elements/Elements.java#L123-L167
|
22,172
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/repeat/UIRepeat.java
|
UIRepeat.saveInitialChildState
|
private void saveInitialChildState(FacesContext facesContext, UIComponent component) {
if (component instanceof EditableValueHolder && !component.isTransient()) {
String clientId = component.getClientId(facesContext);
SavedState state = new SavedState();
initialChildState.put(clientId, state);
state.populate((EditableValueHolder) component);
}
Iterator<UIComponent> iterator = component.getFacetsAndChildren();
while (iterator.hasNext()) {
saveChildState(facesContext, iterator.next());
}
}
|
java
|
private void saveInitialChildState(FacesContext facesContext, UIComponent component) {
if (component instanceof EditableValueHolder && !component.isTransient()) {
String clientId = component.getClientId(facesContext);
SavedState state = new SavedState();
initialChildState.put(clientId, state);
state.populate((EditableValueHolder) component);
}
Iterator<UIComponent> iterator = component.getFacetsAndChildren();
while (iterator.hasNext()) {
saveChildState(facesContext, iterator.next());
}
}
|
[
"private",
"void",
"saveInitialChildState",
"(",
"FacesContext",
"facesContext",
",",
"UIComponent",
"component",
")",
"{",
"if",
"(",
"component",
"instanceof",
"EditableValueHolder",
"&&",
"!",
"component",
".",
"isTransient",
"(",
")",
")",
"{",
"String",
"clientId",
"=",
"component",
".",
"getClientId",
"(",
"facesContext",
")",
";",
"SavedState",
"state",
"=",
"new",
"SavedState",
"(",
")",
";",
"initialChildState",
".",
"put",
"(",
"clientId",
",",
"state",
")",
";",
"state",
".",
"populate",
"(",
"(",
"EditableValueHolder",
")",
"component",
")",
";",
"}",
"Iterator",
"<",
"UIComponent",
">",
"iterator",
"=",
"component",
".",
"getFacetsAndChildren",
"(",
")",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"saveChildState",
"(",
"facesContext",
",",
"iterator",
".",
"next",
"(",
")",
")",
";",
"}",
"}"
] |
Recursively create the initial state for the given component.
@param facesContext the Faces context.
@param component the UI component to save the state for.
@see #saveInitialChildState(javax.faces.context.FacesContext)
|
[
"Recursively",
"create",
"the",
"initial",
"state",
"for",
"the",
"given",
"component",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/repeat/UIRepeat.java#L470-L482
|
22,173
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/cartesian/linear/CartesianLinearTicks.java
|
CartesianLinearTicks.encode
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
ChartUtils.writeDataValue(fsw, "precision", this.precision, true);
ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "beginAtZero", this.beginAtZero, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
ChartUtils.writeDataValue(fsw, "maxTicksLimit", this.maxTicksLimit, true);
ChartUtils.writeDataValue(fsw, "precision", this.precision, true);
ChartUtils.writeDataValue(fsw, "stepSize", this.stepSize, true);
ChartUtils.writeDataValue(fsw, "suggestedMax", this.suggestedMax, true);
ChartUtils.writeDataValue(fsw, "suggestedMin", this.suggestedMin, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"@",
"Override",
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"super",
".",
"encode",
"(",
")",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"beginAtZero\"",
",",
"this",
".",
"beginAtZero",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"min\"",
",",
"this",
".",
"min",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"max\"",
",",
"this",
".",
"max",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"maxTicksLimit\"",
",",
"this",
".",
"maxTicksLimit",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"precision\"",
",",
"this",
".",
"precision",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"stepSize\"",
",",
"this",
".",
"stepSize",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"suggestedMax\"",
",",
"this",
".",
"suggestedMax",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"suggestedMin\"",
",",
"this",
".",
"suggestedMin",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of cartesian linear ticks
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"cartesian",
"linear",
"ticks"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/cartesian/linear/CartesianLinearTicks.java#L198-L218
|
22,174
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearPointLabels.java
|
RadialLinearPointLabels.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "fontSize", this.fontSize, false);
ChartUtils.writeDataValue(fsw, "fontColor", this.fontColor, true);
ChartUtils.writeDataValue(fsw, "fontFamily", this.fontFamily, true);
ChartUtils.writeDataValue(fsw, "fontStyle", this.fontStyle, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "fontSize", this.fontSize, false);
ChartUtils.writeDataValue(fsw, "fontColor", this.fontColor, true);
ChartUtils.writeDataValue(fsw, "fontFamily", this.fontFamily, true);
ChartUtils.writeDataValue(fsw, "fontStyle", this.fontStyle, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"\"{\"",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"fontSize\"",
",",
"this",
".",
"fontSize",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"fontColor\"",
",",
"this",
".",
"fontColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"fontFamily\"",
",",
"this",
".",
"fontFamily",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"fontStyle\"",
",",
"this",
".",
"fontStyle",
",",
"true",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of point labels on radial linear type
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"point",
"labels",
"on",
"radial",
"linear",
"type"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/radial/linear/RadialLinearPointLabels.java#L122-L140
|
22,175
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/cartesian/CartesianTicks.java
|
CartesianTicks.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "autoSkip", this.autoSkip, false);
ChartUtils.writeDataValue(fsw, "autoSkipPadding", this.autoSkipPadding, true);
ChartUtils.writeDataValue(fsw, "labelOffset", this.labelOffset, true);
ChartUtils.writeDataValue(fsw, "maxRotation", this.maxRotation, true);
ChartUtils.writeDataValue(fsw, "minRotation", this.minRotation, true);
ChartUtils.writeDataValue(fsw, "mirror", this.mirror, true);
ChartUtils.writeDataValue(fsw, "padding", this.padding, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "autoSkip", this.autoSkip, false);
ChartUtils.writeDataValue(fsw, "autoSkipPadding", this.autoSkipPadding, true);
ChartUtils.writeDataValue(fsw, "labelOffset", this.labelOffset, true);
ChartUtils.writeDataValue(fsw, "maxRotation", this.maxRotation, true);
ChartUtils.writeDataValue(fsw, "minRotation", this.minRotation, true);
ChartUtils.writeDataValue(fsw, "mirror", this.mirror, true);
ChartUtils.writeDataValue(fsw, "padding", this.padding, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"autoSkip\"",
",",
"this",
".",
"autoSkip",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"autoSkipPadding\"",
",",
"this",
".",
"autoSkipPadding",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"labelOffset\"",
",",
"this",
".",
"labelOffset",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"maxRotation\"",
",",
"this",
".",
"maxRotation",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"minRotation\"",
",",
"this",
".",
"minRotation",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"mirror\"",
",",
"this",
".",
"mirror",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"padding\"",
",",
"this",
".",
"padding",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the common ticks options
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"common",
"ticks",
"options"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/cartesian/CartesianTicks.java#L187-L204
|
22,176
|
primefaces/primefaces
|
src/main/java/org/primefaces/context/PrimeRequestContext.java
|
PrimeRequestContext.isSecure
|
public boolean isSecure() {
// currently called once per request - later we might cache the result per request
// and even the method lookup
Object request = context.getExternalContext().getRequest();
if (request instanceof HttpServletRequest) {
return ((HttpServletRequest) request).isSecure();
}
else {
try {
Method method = request.getClass().getDeclaredMethod("isSecure", new Class[0]);
return (Boolean) method.invoke(request, (Object[]) null);
}
catch (Exception e) {
return false;
}
}
}
|
java
|
public boolean isSecure() {
// currently called once per request - later we might cache the result per request
// and even the method lookup
Object request = context.getExternalContext().getRequest();
if (request instanceof HttpServletRequest) {
return ((HttpServletRequest) request).isSecure();
}
else {
try {
Method method = request.getClass().getDeclaredMethod("isSecure", new Class[0]);
return (Boolean) method.invoke(request, (Object[]) null);
}
catch (Exception e) {
return false;
}
}
}
|
[
"public",
"boolean",
"isSecure",
"(",
")",
"{",
"// currently called once per request - later we might cache the result per request",
"// and even the method lookup",
"Object",
"request",
"=",
"context",
".",
"getExternalContext",
"(",
")",
".",
"getRequest",
"(",
")",
";",
"if",
"(",
"request",
"instanceof",
"HttpServletRequest",
")",
"{",
"return",
"(",
"(",
"HttpServletRequest",
")",
"request",
")",
".",
"isSecure",
"(",
")",
";",
"}",
"else",
"{",
"try",
"{",
"Method",
"method",
"=",
"request",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"isSecure\"",
",",
"new",
"Class",
"[",
"0",
"]",
")",
";",
"return",
"(",
"Boolean",
")",
"method",
".",
"invoke",
"(",
"request",
",",
"(",
"Object",
"[",
"]",
")",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}"
] |
Returns a boolean indicating whether this request was made using a secure channel, such as HTTPS.
@return if secure or not.
|
[
"Returns",
"a",
"boolean",
"indicating",
"whether",
"this",
"request",
"was",
"made",
"using",
"a",
"secure",
"channel",
"such",
"as",
"HTTPS",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/context/PrimeRequestContext.java#L190-L207
|
22,177
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsPoint.java
|
ElementsPoint.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "radius", this.radius, false);
ChartUtils.writeDataValue(fsw, "pointStyle", this.pointStyle, true);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "hitRadius", this.hitRadius, true);
ChartUtils.writeDataValue(fsw, "hoverRadius", this.hoverRadius, true);
ChartUtils.writeDataValue(fsw, "hoverBorderWidth", this.hoverBorderWidth, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "radius", this.radius, false);
ChartUtils.writeDataValue(fsw, "pointStyle", this.pointStyle, true);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "hitRadius", this.hitRadius, true);
ChartUtils.writeDataValue(fsw, "hoverRadius", this.hoverRadius, true);
ChartUtils.writeDataValue(fsw, "hoverBorderWidth", this.hoverBorderWidth, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"radius\"",
",",
"this",
".",
"radius",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"pointStyle\"",
",",
"this",
".",
"pointStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backgroundColor\"",
",",
"this",
".",
"backgroundColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderWidth\"",
",",
"this",
".",
"borderWidth",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderColor\"",
",",
"this",
".",
"borderColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"hitRadius\"",
",",
"this",
".",
"hitRadius",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"hoverRadius\"",
",",
"this",
".",
"hoverRadius",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"hoverBorderWidth\"",
",",
"this",
".",
"hoverBorderWidth",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the point options of Elements
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"point",
"options",
"of",
"Elements"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsPoint.java#L198-L216
|
22,178
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/timeline/TimelineUpdater.java
|
TimelineUpdater.getCurrentInstance
|
public static TimelineUpdater getCurrentInstance(String id) {
FacesContext fc = FacesContext.getCurrentInstance();
@SuppressWarnings("unchecked")
Map<String, TimelineUpdater> map = (Map<String, TimelineUpdater>) fc.getAttributes().get(TimelineUpdater.class.getName());
if (map == null) {
return null;
}
UIComponent timeline = fc.getViewRoot().findComponent(id);
if (timeline == null || !(timeline instanceof Timeline)) {
throw new FacesException("Timeline component with Id " + id + " was not found");
}
TimelineUpdater timelineUpdater = map.get(((Timeline) timeline).resolveWidgetVar());
if (timelineUpdater != null) {
timelineUpdater.id = id;
}
return timelineUpdater;
}
|
java
|
public static TimelineUpdater getCurrentInstance(String id) {
FacesContext fc = FacesContext.getCurrentInstance();
@SuppressWarnings("unchecked")
Map<String, TimelineUpdater> map = (Map<String, TimelineUpdater>) fc.getAttributes().get(TimelineUpdater.class.getName());
if (map == null) {
return null;
}
UIComponent timeline = fc.getViewRoot().findComponent(id);
if (timeline == null || !(timeline instanceof Timeline)) {
throw new FacesException("Timeline component with Id " + id + " was not found");
}
TimelineUpdater timelineUpdater = map.get(((Timeline) timeline).resolveWidgetVar());
if (timelineUpdater != null) {
timelineUpdater.id = id;
}
return timelineUpdater;
}
|
[
"public",
"static",
"TimelineUpdater",
"getCurrentInstance",
"(",
"String",
"id",
")",
"{",
"FacesContext",
"fc",
"=",
"FacesContext",
".",
"getCurrentInstance",
"(",
")",
";",
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"Map",
"<",
"String",
",",
"TimelineUpdater",
">",
"map",
"=",
"(",
"Map",
"<",
"String",
",",
"TimelineUpdater",
">",
")",
"fc",
".",
"getAttributes",
"(",
")",
".",
"get",
"(",
"TimelineUpdater",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"UIComponent",
"timeline",
"=",
"fc",
".",
"getViewRoot",
"(",
")",
".",
"findComponent",
"(",
"id",
")",
";",
"if",
"(",
"timeline",
"==",
"null",
"||",
"!",
"(",
"timeline",
"instanceof",
"Timeline",
")",
")",
"{",
"throw",
"new",
"FacesException",
"(",
"\"Timeline component with Id \"",
"+",
"id",
"+",
"\" was not found\"",
")",
";",
"}",
"TimelineUpdater",
"timelineUpdater",
"=",
"map",
".",
"get",
"(",
"(",
"(",
"Timeline",
")",
"timeline",
")",
".",
"resolveWidgetVar",
"(",
")",
")",
";",
"if",
"(",
"timelineUpdater",
"!=",
"null",
")",
"{",
"timelineUpdater",
".",
"id",
"=",
"id",
";",
"}",
"return",
"timelineUpdater",
";",
"}"
] |
Gets the current thread-safe TimelineUpdater instance by Id.
@param id Id of the Timeline component in terms of findComponent()
@return TimelineUpdater instance.
@throws FacesException if the Timeline component can not be found by the given Id
|
[
"Gets",
"the",
"current",
"thread",
"-",
"safe",
"TimelineUpdater",
"instance",
"by",
"Id",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/timeline/TimelineUpdater.java#L48-L68
|
22,179
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/cartesian/category/CartesianCategoryTicks.java
|
CartesianCategoryTicks.encode
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "labels", this.labels, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
@Override
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write(super.encode());
ChartUtils.writeDataValue(fsw, "labels", this.labels, true);
ChartUtils.writeDataValue(fsw, "min", this.min, true);
ChartUtils.writeDataValue(fsw, "max", this.max, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"@",
"Override",
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"super",
".",
"encode",
"(",
")",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"labels\"",
",",
"this",
".",
"labels",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"min\"",
",",
"this",
".",
"min",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"max\"",
",",
"this",
".",
"max",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the options of cartesian category ticks
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"options",
"of",
"cartesian",
"category",
"ticks"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/cartesian/category/CartesianCategoryTicks.java#L104-L119
|
22,180
|
primefaces/primefaces
|
src/main/java/org/primefaces/component/timeline/TimelineRenderer.java
|
TimelineRenderer.encodeDate
|
private String encodeDate(TimeZone browserTZ, TimeZone targetTZ, Date utcDate) {
return "new Date(" + DateUtils.toLocalDate(browserTZ, targetTZ, utcDate) + ")";
}
|
java
|
private String encodeDate(TimeZone browserTZ, TimeZone targetTZ, Date utcDate) {
return "new Date(" + DateUtils.toLocalDate(browserTZ, targetTZ, utcDate) + ")";
}
|
[
"private",
"String",
"encodeDate",
"(",
"TimeZone",
"browserTZ",
",",
"TimeZone",
"targetTZ",
",",
"Date",
"utcDate",
")",
"{",
"return",
"\"new Date(\"",
"+",
"DateUtils",
".",
"toLocalDate",
"(",
"browserTZ",
",",
"targetTZ",
",",
"utcDate",
")",
"+",
"\")\"",
";",
"}"
] |
convert from UTC to locale date
|
[
"convert",
"from",
"UTC",
"to",
"locale",
"date"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/component/timeline/TimelineRenderer.java#L338-L340
|
22,181
|
primefaces/primefaces
|
src/main/java/org/primefaces/application/exceptionhandler/PrimeExceptionHandler.java
|
PrimeExceptionHandler.buildView
|
protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException {
if (context.getViewRoot() == null) {
ViewHandler viewHandler = context.getApplication().getViewHandler();
String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context));
ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId);
UIViewRoot viewRoot = vdl.createView(context, viewId);
context.setViewRoot(viewRoot);
vdl.buildView(context, viewRoot);
// Workaround for Mojarra
// if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException'
if (rootCause == null && throwable instanceof IllegalArgumentException) {
rootCause = new javax.faces.application.ViewExpiredException(viewId);
}
}
return rootCause;
}
|
java
|
protected Throwable buildView(FacesContext context, Throwable throwable, Throwable rootCause) throws IOException {
if (context.getViewRoot() == null) {
ViewHandler viewHandler = context.getApplication().getViewHandler();
String viewId = viewHandler.deriveViewId(context, ComponentUtils.calculateViewId(context));
ViewDeclarationLanguage vdl = viewHandler.getViewDeclarationLanguage(context, viewId);
UIViewRoot viewRoot = vdl.createView(context, viewId);
context.setViewRoot(viewRoot);
vdl.buildView(context, viewRoot);
// Workaround for Mojarra
// if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException'
if (rootCause == null && throwable instanceof IllegalArgumentException) {
rootCause = new javax.faces.application.ViewExpiredException(viewId);
}
}
return rootCause;
}
|
[
"protected",
"Throwable",
"buildView",
"(",
"FacesContext",
"context",
",",
"Throwable",
"throwable",
",",
"Throwable",
"rootCause",
")",
"throws",
"IOException",
"{",
"if",
"(",
"context",
".",
"getViewRoot",
"(",
")",
"==",
"null",
")",
"{",
"ViewHandler",
"viewHandler",
"=",
"context",
".",
"getApplication",
"(",
")",
".",
"getViewHandler",
"(",
")",
";",
"String",
"viewId",
"=",
"viewHandler",
".",
"deriveViewId",
"(",
"context",
",",
"ComponentUtils",
".",
"calculateViewId",
"(",
"context",
")",
")",
";",
"ViewDeclarationLanguage",
"vdl",
"=",
"viewHandler",
".",
"getViewDeclarationLanguage",
"(",
"context",
",",
"viewId",
")",
";",
"UIViewRoot",
"viewRoot",
"=",
"vdl",
".",
"createView",
"(",
"context",
",",
"viewId",
")",
";",
"context",
".",
"setViewRoot",
"(",
"viewRoot",
")",
";",
"vdl",
".",
"buildView",
"(",
"context",
",",
"viewRoot",
")",
";",
"// Workaround for Mojarra",
"// if UIViewRoot == null -> 'IllegalArgumentException' is throwed instead of 'ViewExpiredException'",
"if",
"(",
"rootCause",
"==",
"null",
"&&",
"throwable",
"instanceof",
"IllegalArgumentException",
")",
"{",
"rootCause",
"=",
"new",
"javax",
".",
"faces",
".",
"application",
".",
"ViewExpiredException",
"(",
"viewId",
")",
";",
"}",
"}",
"return",
"rootCause",
";",
"}"
] |
Builds the view if not already available. This is mostly required for ViewExpiredException's.
@param context The {@link FacesContext}.
@param throwable The occurred {@link Throwable}.
@param rootCause The root cause.
@return The unwrapped {@link Throwable}.
@throws java.io.IOException If building the view fails.
|
[
"Builds",
"the",
"view",
"if",
"not",
"already",
"available",
".",
"This",
"is",
"mostly",
"required",
"for",
"ViewExpiredException",
"s",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/application/exceptionhandler/PrimeExceptionHandler.java#L318-L337
|
22,182
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.addGroup
|
public void addGroup(TimelineGroup group) {
if (groups == null) {
groups = new ArrayList<>();
}
groups.add(group);
}
|
java
|
public void addGroup(TimelineGroup group) {
if (groups == null) {
groups = new ArrayList<>();
}
groups.add(group);
}
|
[
"public",
"void",
"addGroup",
"(",
"TimelineGroup",
"group",
")",
"{",
"if",
"(",
"groups",
"==",
"null",
")",
"{",
"groups",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"groups",
".",
"add",
"(",
"group",
")",
";",
"}"
] |
Adds a given group to the model.
@param group group to be added
|
[
"Adds",
"a",
"given",
"group",
"to",
"the",
"model",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L82-L88
|
22,183
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.add
|
public void add(TimelineEvent event, TimelineUpdater timelineUpdater) {
events.add(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.add(event);
}
}
|
java
|
public void add(TimelineEvent event, TimelineUpdater timelineUpdater) {
events.add(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.add(event);
}
}
|
[
"public",
"void",
"add",
"(",
"TimelineEvent",
"event",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"events",
".",
"add",
"(",
"event",
")",
";",
"if",
"(",
"timelineUpdater",
"!=",
"null",
")",
"{",
"// update UI",
"timelineUpdater",
".",
"add",
"(",
"event",
")",
";",
"}",
"}"
] |
Adds a given event to the model with UI update.
@param event event to be added
@param timelineUpdater TimelineUpdater instance to add the event in UI
|
[
"Adds",
"a",
"given",
"event",
"to",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L96-L103
|
22,184
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.addAllGroups
|
public void addAllGroups(Collection<TimelineGroup> groups) {
if (groups == null) {
groups = new ArrayList<>();
}
groups.addAll(groups);
}
|
java
|
public void addAllGroups(Collection<TimelineGroup> groups) {
if (groups == null) {
groups = new ArrayList<>();
}
groups.addAll(groups);
}
|
[
"public",
"void",
"addAllGroups",
"(",
"Collection",
"<",
"TimelineGroup",
">",
"groups",
")",
"{",
"if",
"(",
"groups",
"==",
"null",
")",
"{",
"groups",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"groups",
".",
"addAll",
"(",
"groups",
")",
";",
"}"
] |
Adds all given groups to the model.
@param groups collection of groups to be added
|
[
"Adds",
"all",
"given",
"groups",
"to",
"the",
"model",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L119-L125
|
22,185
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.addAll
|
public void addAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
add(event, timelineUpdater);
}
}
}
|
java
|
public void addAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
add(event, timelineUpdater);
}
}
}
|
[
"public",
"void",
"addAll",
"(",
"Collection",
"<",
"TimelineEvent",
">",
"events",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"if",
"(",
"events",
"!=",
"null",
"&&",
"!",
"events",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"TimelineEvent",
"event",
":",
"events",
")",
"{",
"add",
"(",
"event",
",",
"timelineUpdater",
")",
";",
"}",
"}",
"}"
] |
Adds all given events to the model with UI update.
@param events collection of events to be added
@param timelineUpdater TimelineUpdater instance to add the events in UI
|
[
"Adds",
"all",
"given",
"events",
"to",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L133-L139
|
22,186
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.update
|
public void update(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (index >= 0) {
events.set(index, event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.update(event, index);
}
}
}
|
java
|
public void update(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (index >= 0) {
events.set(index, event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.update(event, index);
}
}
}
|
[
"public",
"void",
"update",
"(",
"TimelineEvent",
"event",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"int",
"index",
"=",
"getIndex",
"(",
"event",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"events",
".",
"set",
"(",
"index",
",",
"event",
")",
";",
"if",
"(",
"timelineUpdater",
"!=",
"null",
")",
"{",
"// update UI",
"timelineUpdater",
".",
"update",
"(",
"event",
",",
"index",
")",
";",
"}",
"}",
"}"
] |
Updates a given event in the model with UI update.
@param event event to be added
@param timelineUpdater TimelineUpdater instance to update the event in UI
|
[
"Updates",
"a",
"given",
"event",
"in",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L156-L166
|
22,187
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.updateAll
|
public void updateAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
update(event, timelineUpdater);
}
}
}
|
java
|
public void updateAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
update(event, timelineUpdater);
}
}
}
|
[
"public",
"void",
"updateAll",
"(",
"Collection",
"<",
"TimelineEvent",
">",
"events",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"if",
"(",
"events",
"!=",
"null",
"&&",
"!",
"events",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"TimelineEvent",
"event",
":",
"events",
")",
"{",
"update",
"(",
"event",
",",
"timelineUpdater",
")",
";",
"}",
"}",
"}"
] |
Updates all given events in the model with UI update.
@param events collection of events to be updated
@param timelineUpdater TimelineUpdater instance to update the events in UI
|
[
"Updates",
"all",
"given",
"events",
"in",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L183-L189
|
22,188
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.delete
|
public void delete(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (index >= 0) {
events.remove(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.delete(index);
}
}
}
|
java
|
public void delete(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (index >= 0) {
events.remove(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.delete(index);
}
}
}
|
[
"public",
"void",
"delete",
"(",
"TimelineEvent",
"event",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"int",
"index",
"=",
"getIndex",
"(",
"event",
")",
";",
"if",
"(",
"index",
">=",
"0",
")",
"{",
"events",
".",
"remove",
"(",
"event",
")",
";",
"if",
"(",
"timelineUpdater",
"!=",
"null",
")",
"{",
"// update UI",
"timelineUpdater",
".",
"delete",
"(",
"index",
")",
";",
"}",
"}",
"}"
] |
Deletes a given event in the model with UI update.
@param event event to be deleted
@param timelineUpdater TimelineUpdater instance to delete the event in UI
|
[
"Deletes",
"a",
"given",
"event",
"in",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L206-L216
|
22,189
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.deleteAll
|
public void deleteAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
delete(event, timelineUpdater);
}
}
}
|
java
|
public void deleteAll(Collection<TimelineEvent> events, TimelineUpdater timelineUpdater) {
if (events != null && !events.isEmpty()) {
for (TimelineEvent event : events) {
delete(event, timelineUpdater);
}
}
}
|
[
"public",
"void",
"deleteAll",
"(",
"Collection",
"<",
"TimelineEvent",
">",
"events",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"if",
"(",
"events",
"!=",
"null",
"&&",
"!",
"events",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"TimelineEvent",
"event",
":",
"events",
")",
"{",
"delete",
"(",
"event",
",",
"timelineUpdater",
")",
";",
"}",
"}",
"}"
] |
Deletes all given events in the model with UI update.
@param events collection of events to be deleted
@param timelineUpdater TimelineUpdater instance to delete the events in UI
|
[
"Deletes",
"all",
"given",
"events",
"in",
"the",
"model",
"with",
"UI",
"update",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L233-L239
|
22,190
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.select
|
public void select(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.select(index);
}
}
|
java
|
public void select(TimelineEvent event, TimelineUpdater timelineUpdater) {
int index = getIndex(event);
if (timelineUpdater != null) {
// update UI
timelineUpdater.select(index);
}
}
|
[
"public",
"void",
"select",
"(",
"TimelineEvent",
"event",
",",
"TimelineUpdater",
"timelineUpdater",
")",
"{",
"int",
"index",
"=",
"getIndex",
"(",
"event",
")",
";",
"if",
"(",
"timelineUpdater",
"!=",
"null",
")",
"{",
"// update UI",
"timelineUpdater",
".",
"select",
"(",
"index",
")",
";",
"}",
"}"
] |
Selects a given event in UI visually. To unselect all events, pass a null as event.
@param event event to be selected
@param timelineUpdater TimelineUpdater instance to select the event in UI
|
[
"Selects",
"a",
"given",
"event",
"in",
"UI",
"visually",
".",
"To",
"unselect",
"all",
"events",
"pass",
"a",
"null",
"as",
"event",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L247-L254
|
22,191
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.getOverlappedEvents
|
public TreeSet<TimelineEvent> getOverlappedEvents(TimelineEvent event) {
if (event == null) {
return null;
}
List<TimelineEvent> overlappedEvents = null;
for (TimelineEvent e : events) {
if (e.equals(event)) {
// given event should not be included
continue;
}
if (event.getGroup() == null && e.getGroup() != null
|| (event.getGroup() != null && !event.getGroup().equals(e.getGroup()))) {
// ignore different groups
continue;
}
if (isOverlapping(event, e)) {
if (overlappedEvents == null) {
overlappedEvents = new ArrayList<>();
}
overlappedEvents.add(e);
}
}
if (overlappedEvents == null) {
return null;
}
// order overlapped events according to their start / end dates
TreeSet<TimelineEvent> orderedOverlappedEvents = new TreeSet<>(new TimelineEventComparator());
orderedOverlappedEvents.addAll(overlappedEvents);
return orderedOverlappedEvents;
}
|
java
|
public TreeSet<TimelineEvent> getOverlappedEvents(TimelineEvent event) {
if (event == null) {
return null;
}
List<TimelineEvent> overlappedEvents = null;
for (TimelineEvent e : events) {
if (e.equals(event)) {
// given event should not be included
continue;
}
if (event.getGroup() == null && e.getGroup() != null
|| (event.getGroup() != null && !event.getGroup().equals(e.getGroup()))) {
// ignore different groups
continue;
}
if (isOverlapping(event, e)) {
if (overlappedEvents == null) {
overlappedEvents = new ArrayList<>();
}
overlappedEvents.add(e);
}
}
if (overlappedEvents == null) {
return null;
}
// order overlapped events according to their start / end dates
TreeSet<TimelineEvent> orderedOverlappedEvents = new TreeSet<>(new TimelineEventComparator());
orderedOverlappedEvents.addAll(overlappedEvents);
return orderedOverlappedEvents;
}
|
[
"public",
"TreeSet",
"<",
"TimelineEvent",
">",
"getOverlappedEvents",
"(",
"TimelineEvent",
"event",
")",
"{",
"if",
"(",
"event",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"List",
"<",
"TimelineEvent",
">",
"overlappedEvents",
"=",
"null",
";",
"for",
"(",
"TimelineEvent",
"e",
":",
"events",
")",
"{",
"if",
"(",
"e",
".",
"equals",
"(",
"event",
")",
")",
"{",
"// given event should not be included",
"continue",
";",
"}",
"if",
"(",
"event",
".",
"getGroup",
"(",
")",
"==",
"null",
"&&",
"e",
".",
"getGroup",
"(",
")",
"!=",
"null",
"||",
"(",
"event",
".",
"getGroup",
"(",
")",
"!=",
"null",
"&&",
"!",
"event",
".",
"getGroup",
"(",
")",
".",
"equals",
"(",
"e",
".",
"getGroup",
"(",
")",
")",
")",
")",
"{",
"// ignore different groups",
"continue",
";",
"}",
"if",
"(",
"isOverlapping",
"(",
"event",
",",
"e",
")",
")",
"{",
"if",
"(",
"overlappedEvents",
"==",
"null",
")",
"{",
"overlappedEvents",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"}",
"overlappedEvents",
".",
"add",
"(",
"e",
")",
";",
"}",
"}",
"if",
"(",
"overlappedEvents",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"// order overlapped events according to their start / end dates",
"TreeSet",
"<",
"TimelineEvent",
">",
"orderedOverlappedEvents",
"=",
"new",
"TreeSet",
"<>",
"(",
"new",
"TimelineEventComparator",
"(",
")",
")",
";",
"orderedOverlappedEvents",
".",
"addAll",
"(",
"overlappedEvents",
")",
";",
"return",
"orderedOverlappedEvents",
";",
"}"
] |
Gets all overlapped events to the given one. The given and overlapped events belong to the same group. Events are ordered
by their start dates - first events with more recent start dates and then events with older start dates. If start dates are
equal, events will be ordered by their end dates. In this case, if an event has a null end date, it is ordered before the
event with a not null end date.
@param event given event
@return TreeSet<TimelineEvent> ordered overlapped events or null if no overlapping exist
|
[
"Gets",
"all",
"overlapped",
"events",
"to",
"the",
"given",
"one",
".",
"The",
"given",
"and",
"overlapped",
"events",
"belong",
"to",
"the",
"same",
"group",
".",
"Events",
"are",
"ordered",
"by",
"their",
"start",
"dates",
"-",
"first",
"events",
"with",
"more",
"recent",
"start",
"dates",
"and",
"then",
"events",
"with",
"older",
"start",
"dates",
".",
"If",
"start",
"dates",
"are",
"equal",
"events",
"will",
"be",
"ordered",
"by",
"their",
"end",
"dates",
".",
"In",
"this",
"case",
"if",
"an",
"event",
"has",
"a",
"null",
"end",
"date",
"it",
"is",
"ordered",
"before",
"the",
"event",
"with",
"a",
"not",
"null",
"end",
"date",
"."
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L286-L322
|
22,192
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.getEvent
|
public TimelineEvent getEvent(String index) {
return getEvent(index != null ? Integer.valueOf(index) : -1);
}
|
java
|
public TimelineEvent getEvent(String index) {
return getEvent(index != null ? Integer.valueOf(index) : -1);
}
|
[
"public",
"TimelineEvent",
"getEvent",
"(",
"String",
"index",
")",
"{",
"return",
"getEvent",
"(",
"index",
"!=",
"null",
"?",
"Integer",
".",
"valueOf",
"(",
"index",
")",
":",
"-",
"1",
")",
";",
"}"
] |
Gets event by its index as String
@param index index
@return TimelineEvent found event or null
|
[
"Gets",
"event",
"by",
"its",
"index",
"as",
"String"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L436-L438
|
22,193
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/timeline/TimelineModel.java
|
TimelineModel.getIndex
|
public int getIndex(TimelineEvent event) {
int index = -1;
if (event != null) {
for (int i = 0; i < events.size(); i++) {
if (events.get(i).equals(event)) {
index = i;
break;
}
}
}
return index;
}
|
java
|
public int getIndex(TimelineEvent event) {
int index = -1;
if (event != null) {
for (int i = 0; i < events.size(); i++) {
if (events.get(i).equals(event)) {
index = i;
break;
}
}
}
return index;
}
|
[
"public",
"int",
"getIndex",
"(",
"TimelineEvent",
"event",
")",
"{",
"int",
"index",
"=",
"-",
"1",
";",
"if",
"(",
"event",
"!=",
"null",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"events",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"if",
"(",
"events",
".",
"get",
"(",
"i",
")",
".",
"equals",
"(",
"event",
")",
")",
"{",
"index",
"=",
"i",
";",
"break",
";",
"}",
"}",
"}",
"return",
"index",
";",
"}"
] |
Gets index of the given timeline event
@param event given event
@return int positive index or -1 if the given event is not available in the timeline
|
[
"Gets",
"index",
"of",
"the",
"given",
"timeline",
"event"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/timeline/TimelineModel.java#L460-L474
|
22,194
|
primefaces/primefaces
|
src/main/java/org/primefaces/el/InterceptingResolver.java
|
InterceptingResolver.setValue
|
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
// currently not used -> see #7114
if (base != null && property != null) {
context.setPropertyResolved(true);
valueReference = new ValueReference(base, property.toString());
}
}
|
java
|
@Override
public void setValue(ELContext context, Object base, Object property, Object value) {
// currently not used -> see #7114
if (base != null && property != null) {
context.setPropertyResolved(true);
valueReference = new ValueReference(base, property.toString());
}
}
|
[
"@",
"Override",
"public",
"void",
"setValue",
"(",
"ELContext",
"context",
",",
"Object",
"base",
",",
"Object",
"property",
",",
"Object",
"value",
")",
"{",
"// currently not used -> see #7114",
"if",
"(",
"base",
"!=",
"null",
"&&",
"property",
"!=",
"null",
")",
"{",
"context",
".",
"setPropertyResolved",
"(",
"true",
")",
";",
"valueReference",
"=",
"new",
"ValueReference",
"(",
"base",
",",
"property",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] |
Capture the base and property rather than write the value
|
[
"Capture",
"the",
"base",
"and",
"property",
"rather",
"than",
"write",
"the",
"value"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/el/InterceptingResolver.java#L47-L54
|
22,195
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsLine.java
|
ElementsLine.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "tension", this.tension, false);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "borderCapStyle", this.borderCapStyle, true);
ChartUtils.writeDataValue(fsw, "borderDash", this.borderDash, true);
ChartUtils.writeDataValue(fsw, "borderDashOffset", this.borderDashOffset, true);
ChartUtils.writeDataValue(fsw, "borderJoinStyle", this.borderJoinStyle, true);
ChartUtils.writeDataValue(fsw, "capBezierPoints", this.capBezierPoints, true);
ChartUtils.writeDataValue(fsw, "fill", this.fill, true);
ChartUtils.writeDataValue(fsw, "stepped", this.stepped, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
ChartUtils.writeDataValue(fsw, "tension", this.tension, false);
ChartUtils.writeDataValue(fsw, "backgroundColor", this.backgroundColor, true);
ChartUtils.writeDataValue(fsw, "borderWidth", this.borderWidth, true);
ChartUtils.writeDataValue(fsw, "borderColor", this.borderColor, true);
ChartUtils.writeDataValue(fsw, "borderCapStyle", this.borderCapStyle, true);
ChartUtils.writeDataValue(fsw, "borderDash", this.borderDash, true);
ChartUtils.writeDataValue(fsw, "borderDashOffset", this.borderDashOffset, true);
ChartUtils.writeDataValue(fsw, "borderJoinStyle", this.borderJoinStyle, true);
ChartUtils.writeDataValue(fsw, "capBezierPoints", this.capBezierPoints, true);
ChartUtils.writeDataValue(fsw, "fill", this.fill, true);
ChartUtils.writeDataValue(fsw, "stepped", this.stepped, true);
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"tension\"",
",",
"this",
".",
"tension",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"backgroundColor\"",
",",
"this",
".",
"backgroundColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderWidth\"",
",",
"this",
".",
"borderWidth",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderColor\"",
",",
"this",
".",
"borderColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderCapStyle\"",
",",
"this",
".",
"borderCapStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderDash\"",
",",
"this",
".",
"borderDash",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderDashOffset\"",
",",
"this",
".",
"borderDashOffset",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderJoinStyle\"",
",",
"this",
".",
"borderJoinStyle",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"capBezierPoints\"",
",",
"this",
".",
"capBezierPoints",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"fill\"",
",",
"this",
".",
"fill",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"stepped\"",
",",
"this",
".",
"stepped",
",",
"true",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the line options of Elements
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"line",
"options",
"of",
"Elements"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/optionconfig/elements/ElementsLine.java#L256-L277
|
22,196
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/CalendarUtils.java
|
CalendarUtils.convertPattern
|
public static final String convertPattern(String pattern) {
if (pattern == null) {
return null;
}
else {
String convertedPattern = pattern;
for (PatternConverter converter : PATTERN_CONVERTERS) {
convertedPattern = converter.convert(convertedPattern);
}
return convertedPattern;
}
}
|
java
|
public static final String convertPattern(String pattern) {
if (pattern == null) {
return null;
}
else {
String convertedPattern = pattern;
for (PatternConverter converter : PATTERN_CONVERTERS) {
convertedPattern = converter.convert(convertedPattern);
}
return convertedPattern;
}
}
|
[
"public",
"static",
"final",
"String",
"convertPattern",
"(",
"String",
"pattern",
")",
"{",
"if",
"(",
"pattern",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"String",
"convertedPattern",
"=",
"pattern",
";",
"for",
"(",
"PatternConverter",
"converter",
":",
"PATTERN_CONVERTERS",
")",
"{",
"convertedPattern",
"=",
"converter",
".",
"convert",
"(",
"convertedPattern",
")",
";",
"}",
"return",
"convertedPattern",
";",
"}",
"}"
] |
Converts a java date pattern to a jquery date pattern
@param pattern Pattern to be converted
@return converted pattern
|
[
"Converts",
"a",
"java",
"date",
"pattern",
"to",
"a",
"jquery",
"date",
"pattern"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/CalendarUtils.java#L198-L210
|
22,197
|
primefaces/primefaces
|
src/main/java/org/primefaces/util/CalendarUtils.java
|
CalendarUtils.encodeListValue
|
public static void encodeListValue(FacesContext context, UICalendar uicalendar, String optionName, List<Object> values) throws IOException {
if (values == null) {
return;
}
ResponseWriter writer = context.getResponseWriter();
writer.write("," + optionName + ":[");
for (int i = 0; i < values.size(); i++) {
Object item = values.get(i);
Object preText = (i == 0) ? "" : ",";
if (item instanceof Date) {
writer.write(preText + "\"" + EscapeUtils.forJavaScript(getValueAsString(context, uicalendar, item)) + "\"");
}
else {
writer.write(preText + "" + item);
}
}
writer.write("]");
}
|
java
|
public static void encodeListValue(FacesContext context, UICalendar uicalendar, String optionName, List<Object> values) throws IOException {
if (values == null) {
return;
}
ResponseWriter writer = context.getResponseWriter();
writer.write("," + optionName + ":[");
for (int i = 0; i < values.size(); i++) {
Object item = values.get(i);
Object preText = (i == 0) ? "" : ",";
if (item instanceof Date) {
writer.write(preText + "\"" + EscapeUtils.forJavaScript(getValueAsString(context, uicalendar, item)) + "\"");
}
else {
writer.write(preText + "" + item);
}
}
writer.write("]");
}
|
[
"public",
"static",
"void",
"encodeListValue",
"(",
"FacesContext",
"context",
",",
"UICalendar",
"uicalendar",
",",
"String",
"optionName",
",",
"List",
"<",
"Object",
">",
"values",
")",
"throws",
"IOException",
"{",
"if",
"(",
"values",
"==",
"null",
")",
"{",
"return",
";",
"}",
"ResponseWriter",
"writer",
"=",
"context",
".",
"getResponseWriter",
"(",
")",
";",
"writer",
".",
"write",
"(",
"\",\"",
"+",
"optionName",
"+",
"\":[\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"values",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"Object",
"item",
"=",
"values",
".",
"get",
"(",
"i",
")",
";",
"Object",
"preText",
"=",
"(",
"i",
"==",
"0",
")",
"?",
"\"\"",
":",
"\",\"",
";",
"if",
"(",
"item",
"instanceof",
"Date",
")",
"{",
"writer",
".",
"write",
"(",
"preText",
"+",
"\"\\\"\"",
"+",
"EscapeUtils",
".",
"forJavaScript",
"(",
"getValueAsString",
"(",
"context",
",",
"uicalendar",
",",
"item",
")",
")",
"+",
"\"\\\"\"",
")",
";",
"}",
"else",
"{",
"writer",
".",
"write",
"(",
"preText",
"+",
"\"\"",
"+",
"item",
")",
";",
"}",
"}",
"writer",
".",
"write",
"(",
"\"]\"",
")",
";",
"}"
] |
Write the value of Calendar options
@param context
@param uicalendar component
@param optionName the name of an option
@param values the List values of an option
@throws java.io.IOException if writer is null
|
[
"Write",
"the",
"value",
"of",
"Calendar",
"options"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/util/CalendarUtils.java#L221-L242
|
22,198
|
primefaces/primefaces
|
src/main/java/org/primefaces/model/charts/axes/AxesGridLines.java
|
AxesGridLines.encode
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "display", this.display, false);
ChartUtils.writeDataValue(fsw, "color", this.color, true);
ChartUtils.writeDataValue(fsw, "borderDash", this.borderDash, true);
ChartUtils.writeDataValue(fsw, "borderDashOffset", this.borderDashOffset, true);
ChartUtils.writeDataValue(fsw, "lineWidth", this.lineWidth, true);
ChartUtils.writeDataValue(fsw, "drawBorder", this.drawBorder, true);
ChartUtils.writeDataValue(fsw, "drawOnChartArea", this.drawOnChartArea, true);
ChartUtils.writeDataValue(fsw, "drawTicks", this.drawTicks, true);
ChartUtils.writeDataValue(fsw, "tickMarkLength", this.tickMarkLength, true);
ChartUtils.writeDataValue(fsw, "zeroLineWidth", this.zeroLineWidth, true);
ChartUtils.writeDataValue(fsw, "zeroLineColor", this.zeroLineColor, true);
ChartUtils.writeDataValue(fsw, "zeroLineBorderDash", this.zeroLineBorderDash, true);
ChartUtils.writeDataValue(fsw, "zeroLineBorderDashOffset", this.zeroLineBorderDashOffset, true);
ChartUtils.writeDataValue(fsw, "offsetGridLines", this.offsetGridLines, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
java
|
public String encode() throws IOException {
FastStringWriter fsw = new FastStringWriter();
try {
fsw.write("{");
ChartUtils.writeDataValue(fsw, "display", this.display, false);
ChartUtils.writeDataValue(fsw, "color", this.color, true);
ChartUtils.writeDataValue(fsw, "borderDash", this.borderDash, true);
ChartUtils.writeDataValue(fsw, "borderDashOffset", this.borderDashOffset, true);
ChartUtils.writeDataValue(fsw, "lineWidth", this.lineWidth, true);
ChartUtils.writeDataValue(fsw, "drawBorder", this.drawBorder, true);
ChartUtils.writeDataValue(fsw, "drawOnChartArea", this.drawOnChartArea, true);
ChartUtils.writeDataValue(fsw, "drawTicks", this.drawTicks, true);
ChartUtils.writeDataValue(fsw, "tickMarkLength", this.tickMarkLength, true);
ChartUtils.writeDataValue(fsw, "zeroLineWidth", this.zeroLineWidth, true);
ChartUtils.writeDataValue(fsw, "zeroLineColor", this.zeroLineColor, true);
ChartUtils.writeDataValue(fsw, "zeroLineBorderDash", this.zeroLineBorderDash, true);
ChartUtils.writeDataValue(fsw, "zeroLineBorderDashOffset", this.zeroLineBorderDashOffset, true);
ChartUtils.writeDataValue(fsw, "offsetGridLines", this.offsetGridLines, true);
fsw.write("}");
}
finally {
fsw.close();
}
return fsw.toString();
}
|
[
"public",
"String",
"encode",
"(",
")",
"throws",
"IOException",
"{",
"FastStringWriter",
"fsw",
"=",
"new",
"FastStringWriter",
"(",
")",
";",
"try",
"{",
"fsw",
".",
"write",
"(",
"\"{\"",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"display\"",
",",
"this",
".",
"display",
",",
"false",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"color\"",
",",
"this",
".",
"color",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderDash\"",
",",
"this",
".",
"borderDash",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"borderDashOffset\"",
",",
"this",
".",
"borderDashOffset",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"lineWidth\"",
",",
"this",
".",
"lineWidth",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"drawBorder\"",
",",
"this",
".",
"drawBorder",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"drawOnChartArea\"",
",",
"this",
".",
"drawOnChartArea",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"drawTicks\"",
",",
"this",
".",
"drawTicks",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"tickMarkLength\"",
",",
"this",
".",
"tickMarkLength",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"zeroLineWidth\"",
",",
"this",
".",
"zeroLineWidth",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"zeroLineColor\"",
",",
"this",
".",
"zeroLineColor",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"zeroLineBorderDash\"",
",",
"this",
".",
"zeroLineBorderDash",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"zeroLineBorderDashOffset\"",
",",
"this",
".",
"zeroLineBorderDashOffset",
",",
"true",
")",
";",
"ChartUtils",
".",
"writeDataValue",
"(",
"fsw",
",",
"\"offsetGridLines\"",
",",
"this",
".",
"offsetGridLines",
",",
"true",
")",
";",
"fsw",
".",
"write",
"(",
"\"}\"",
")",
";",
"}",
"finally",
"{",
"fsw",
".",
"close",
"(",
")",
";",
"}",
"return",
"fsw",
".",
"toString",
"(",
")",
";",
"}"
] |
Write the common ticks options of axes
@return options as JSON object
@throws java.io.IOException If an I/O error occurs
|
[
"Write",
"the",
"common",
"ticks",
"options",
"of",
"axes"
] |
b8cdd5ed395d09826e40e3302d6b14901d3ef4e7
|
https://github.com/primefaces/primefaces/blob/b8cdd5ed395d09826e40e3302d6b14901d3ef4e7/src/main/java/org/primefaces/model/charts/axes/AxesGridLines.java#L316-L344
|
22,199
|
prometheus/client_java
|
simpleclient/src/main/java/io/prometheus/client/Histogram.java
|
Histogram.build
|
public static Builder build(String name, String help) {
return new Builder().name(name).help(help);
}
|
java
|
public static Builder build(String name, String help) {
return new Builder().name(name).help(help);
}
|
[
"public",
"static",
"Builder",
"build",
"(",
"String",
"name",
",",
"String",
"help",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
".",
"name",
"(",
"name",
")",
".",
"help",
"(",
"help",
")",
";",
"}"
] |
Return a Builder to allow configuration of a new Histogram. Ensures required fields are provided.
@param name The name of the metric
@param help The help string of the metric
|
[
"Return",
"a",
"Builder",
"to",
"allow",
"configuration",
"of",
"a",
"new",
"Histogram",
".",
"Ensures",
"required",
"fields",
"are",
"provided",
"."
] |
4e0e7527b048f1ffd0382dcb74c0b9dab23b4d9f
|
https://github.com/prometheus/client_java/blob/4e0e7527b048f1ffd0382dcb74c0b9dab23b4d9f/simpleclient/src/main/java/io/prometheus/client/Histogram.java#L140-L142
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.