Expected Resource or Concept in hyperledger-composer playground - hyperledger-composer

I have an error said "Expected Resource or Concept" in playground hyperledger-composer
Two participants
1. School
2. Company
Two assets
1. Transcript
2. Transcript_status
One transaction updateStatus:
• Update student’s transcript status from unread to either not interested or interested
Participant school, student, company
Assets Transcript, Transcript_status
Transaction updateStatus
School creates a participant school
Company creates a participant company
School creates an asset transcript
Company creates an asset transcript_status
Workflow: After creating student’s asset (transcript), schools can upload the record to its website, and companies can view the first asset Transcript. After that, companies can submit transaction Transcript_status and marked as read. Then the asset Transcript_status will be updated from unread to read.
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Definition of a Bond, based on the FpML schema:
* http://www.fpml.org/spec/fpml-5-3-2-wd-2/html/reporting/schemaDocumentation/schemas/fpml-asset-5-3_xsd/elements/bond.html
*
*/
namespace org.school.education
participant School identified by Schoolid {
o String Schoolid
o String name
}
participant Company identified by Companytid {
o String Companytid
o String name
}
participant Student identified by Studentid {
o String Studentid
o String studentName
o String ClassofYear
}
asset Transcript identified by tId{
o String tId
o String name
o String ClassofYear
o String gpa
o String major
o String jobexp optional
o String nationality
o Boolean readStatus default=false
--> School school
}
asset TranscriptStatus identified by tsId{
o String tsId
o String name
o String status
o String ReviewedCompany
--> Company company
}
transaction UpdateTranscript_status {
o String studentName
o Boolean readStatus default=false
--> School school
}
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* global getAssetRegistry */
'use strict';
/**
* Process a property that is held for sale
* #param {org.school.education.UpdateTranscript_status} updateTranscript the transcript to be updated
* #transaction
*/
async function transcriptForUpdated(TforUpdated) { // eslint-disable-line no-unused-vars
console.log('### transcriptForUpdated ' + TforUpdated.toString());
TforUpdated.readStatus = true;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.readStatus);
}
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Sample access control list.
*/
rule EverybodyCanReadEverything {
description: "Allow all participants read access to all resources"
participant: "org.school.education.School"
operation: READ
resource: "org.school.education.*"
action: ALLOW
}
rule EverybodyCanSubmitTransactions {
description: "Allow all participants to submit transactions"
participant: "org.school.education.School"
operation: CREATE
resource: "org.schoo;.education.UpdateTranscript_status"
action: ALLOW
}
rule OwnerHasFullAccessToTheirAssets {
description: "Allow all participants full access to their assets"
participant(p): "org.school.education.School"
operation: ALL
resource(r): "org.school.education.Transcript"
condition: (r.owner.getIdentifier() === p.getIdentifier())
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule NetworkAdminUser {
description: "Grant business network administrators full access to user resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "**"
action: ALLOW
}
rule NetworkAdminSystem {
description: "Grant business network administrators full access to system resources"
participant: "org.hyperledger.composer.system.NetworkAdmin"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}

As per my understanding, I run your code. I had fix some issues. In your code, you may update a readStatus under a transcript asset. If you update a single value under s asset so you need to put an object of that asset in the Update function.
1. Model File Changes:
transaction UpdateTranscript_status {
o Boolean readStatus default=false
--> Transcript transcript
}
2. logic.js Changes:
async function transcriptForUpdated(TforUpdated) {
// eslint-disable-line no-unused-vars
TforUpdated.readStatus = true;
TforUpdated.transcript.readStatus = TforUpdated.readStatus;
const registry = await getAssetRegistry('org.school.education.Transcript');
await registry.update(TforUpdated.transcript);
}
After Running this transaction it will update a readStatus (false value update by true) under a Transcript asset.
Hope it will fix your issue :)

Related

How to describe websocket api using Apidoc?

This issue "Documenting WebSockets #501"
said "apiDoc was not designed for websockets, but i think you can use it too. The #api /endpoint/path must be replaced with the function / message name, the parameters could be documented the same way."
This is my code :
/**
* #api onBinaryMessage Set a binary message handler on the connection.
*
* #apiGroup websocket
* #apiParam {Buffer} buffer
* #apiParam {ServerWebSocket} websocket
*/
result
Is there a standard usage? Orz

A participant using transaction to update/add another participant

Suppose I create two Participant type A and B respectively, and a transaction X which can only be executed by participant type B or admin.
Moreover, I added some permission rule that Participant A can be created/updated only by the admin or other Participant of type A.
Now, my logic in transaction X requires creation/updating of Participant A. So, If I execute the transaction X using one of the Participant B registry ID, will it be able to create/update the participant A? If not, then is there any way to do so?
If I have understood your requirement correctly, then these rules should work for the core of what you want:
(This example uses the default Basic Sample Network)
rule BforX {
description: "Allow B access to transaction X"
participant: "org.example.basic.SampleParticipantB"
operation: READ, CREATE, UPDATE
resource: "org.example.basic.SampleTransactionX"
action: ALLOW
}
rule BforAinX {
description: "Allow B access to A whilst in X"
participant: "org.example.basic.SampleParticipantB"
operation: READ, CREATE, UPDATE
resource: "org.example.basic.SampleParticipantA"
transaction: "org.example.basic.SampleTransactionX"
action: ALLOW
}
rule NotAforX {
description: "Deny A access to transaction X"
participant: "org.example.basic.SampleParticipantA"
operation: ALL
resource: "org.example.basic.SampleTransactionX"
action: DENY
}
rule AforA {
description: "Allow A access to Participant_A"
participant: "org.example.basic.SampleParticipantA"
operation: READ, CREATE, UPDATE
resource: "org.example.basic.SampleParticipantA"
action: ALLOW
}

#returns throwing error when running locally on docker

I'm trying to return array of asset from transaction. So as per the syntax I have added #returns and #commit(false) in cto file but its throwing error as
✖ Installing business network. This may take a minute...
ParseException: Expected ")", "-", "false", "true", comment, end of
line, number, string or whitespace but "P" found. File
models/org.zcon.healthcare.cto line 370 column 10
Command failed
And when i'm removing the #returns annotation its not throwing any error.
And well its not throwing any error when i'm removing parameter "Patient[]" from #returns annotation.. But it's against the syntax right?
I'm running the application locally using docker swarm.
My docker composer version is v0.19.12
What's wrong? Is this any bug?
In case if you want to see the transaction definition in cto file.
#commit(false)
#returns(Patient[])
transaction SearchPatient{
o String firstName optional
o String lastName optional
}
And in logic file
/**
* Sample transaction
* #param {org.zcon.healthcare.SearchPatient} tx
* #returns{org.zcon.healthcare.Patient[]}
* #transaction
*/
async function SearchPatient(tx){
let queryString = `SELECT org.zcon.healthcare.Patient WHERE (`;
let conditions = [];
if (tx.hasOwnProperty('firstName')) {
var firstName =tx.firstName;
conditions.push(`(firstName == "${firstName}")`)
};
if (tx.hasOwnProperty('lastName')) {
var lastName = tx.lastName;
conditions.push(`(lastName == "${lastName}")`)
};
queryString += conditions.join(' AND ') + ')';
let finalQuery = buildQuery(queryString);
const searchPatient = await query(finalQuery);
if(searchPatient.length ==0){
throw "No Patient Records found!!"
}else
return searchPatient;
}
I've not seen this error with composer network install (deploying to a running Fabric) I did the network install just fine (see screenshot) with your model and code. I suggest that your error may lie elsewhere in your business network ? Can you add the complete sequence of what you got to get the error? How did you build your bna file?
I also tried your code (ending....):
const searchPatient = await query(finalQuery);
console.log("results are " + searchPatient);
console.log("element 1 of array is " + searchPatient[0]);
if(searchPatient.length ==0){
throw "No Patient Records found!!"
} else
return searchPatient;
}
and can see the returned results fine (as shown in console.log - just using a different network name obviously FYI)

SimpleSAMLPHP Unhandled exception failed to parse xml string

SimpleSAML_Error_Error: UNHANDLEDEXCEPTION
Backtrace:
0 C:\xamp\htdocs\okta\simplesamlphp\www\module.php:180 (N/A)
Caused by: Exception: Failed to parse XML string.
Backtrace:
7 C:\xamp\htdocs\okta\simplesamlphp\lib\SimpleSAML\Metadata\SAMLParser.php:333 (SimpleSAML_Metadata_SAMLParser::parseDescriptorsString)
6 C:\xamp\htdocs\okta\simplesamlphp\saml-autoconfig.php:54 (require)
5 C:\xamp\htdocs\okta\simplesamlphp\config\authsources.php:2 (require)
4 C:\xamp\htdocs\okta\simplesamlphp\lib\SimpleSAML\Configuration.php:114 (SimpleSAML_Configuration::loadFromFile)
3 C:\xamp\htdocs\okta\simplesamlphp\lib\SimpleSAML\Configuration.php:178 (SimpleSAML_Configuration::getConfig)
2 C:\xamp\htdocs\okta\simplesamlphp\lib\SimpleSAML\Auth\Source.php:330 (SimpleSAML_Auth_Source::getById)
1 C:\xamp\htdocs\okta\simplesamlphp\modules\saml\www\sp\saml2-acs.php:12 (require)
0 C:\xamp\htdocs\okta\simplesamlphp\www\module.php:137 (N/A)
saml-autoconfig.php
<?php
/* -*- coding: utf-8 -*-
* Copyright 2015 Okta, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* metadata_url_for contains PER APPLICATION configuration settings.
* Each SAML service that you support will have different values here.
*
* NOTE:
* This is implemented as an array for DEMONSTRATION PURPOSES ONLY.
* On a production system, this information should be stored as approprate
* With each key below mapping to your concept of "customer company",
* "group", "organization", "team", etc.
* This should also be stored in your production datastore.
*/
$metadata_url_for = array(
/* WARNING WARNING WARNING
* You MUST remove the testing IdP (idp.oktadev.com) from a production system,
* as the testing IdP will allow ANYBODY to log in as ANY USER!
* WARNING WARNING WARNING
* For testing with http://saml.oktadev.com use the line below:
*/
// 'test' => 'http://idp.oktadev.com/metadata',
'example' => 'https://dev-540405.oktapreview.com/app/weblogpkdev930725_weblog_1/exk8fuhzpynnGw54Q0h7/sso/saml',
);
foreach($metadata_url_for as $idp_name => $metadata_url) {
/*
* Fetch SAML metadata from the URL.
* NOTE:
* SAML metadata changes very rarely. On a production system,
* this data should be cached as approprate for your production system.
*/
$metadata_xml = file_get_contents($metadata_url);
/*
* Parse the SAML metadata using SimpleSAMLphp's parser.
* See also: modules/metaedit/www/edit.php:34
*/
SimpleSAML_Utilities::validateXMLDocument($metadata_xml, 'saml-meta');
$entities = SimpleSAML_Metadata_SAMLParser::parseDescriptorsString($metadata_xml);
$entity = array_pop($entities);
$idp = $entity->getMetadata20IdP();
$entity_id = $idp['entityid'];
/*
* Remove HTTP-POST endpoints from metadata,
* since we only want to make HTTP-GET AuthN requests.
*/
for($x = 0; $x < sizeof($idp['SingleSignOnService']); $x++) {
$endpoint = $idp['SingleSignOnService'][$x];
if($endpoint['Binding'] == 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST') {
unset($idp['SingleSignOnService'][$x]);
}
}
/*
* Don't sign AuthN requests.
*/
if(isset($idp['sign.authnrequest'])) {
unset($idp['sign.authnrequest']);
}
/*
* Set up the "$config" and "$metadata" variables as used by SimpleSAMLphp.
*/
$config[$idp_name] = array(
'saml:SP',
'entityID' => null,
'idp' => $entity_id,
// NOTE: This is how you configure RelayState on the server side.
// 'RelayState' => "",
);
$metadata[$entity_id] = $idp;
}
it seems like there is an error on the configuration you have done in the SimpleSAMLPhp. Can you please provide the configuration you have done inside saml-autoconfig.php file as well as under config.php?

Outlook API: Getting free/busy status

I searched around but couldn't find an answer. I'm not sure if this is possible, but seems it is.
What I basically want is to get my free/busy status according to Outlook in to a C++ program. For example, I want to check if I have an appointment and then print out "Free" or "Busy". Of course it will awesome if I can also get an description of the appointment.
Is there an easier way of doing this?
Any tutorial or example link owuld be greatly appreciated.
Thank you.
I think this link should help . Let me know.
I am providing the contents of the link below :-
Checking Free/Busy Status
Exchange Server 2003 - Checking Free/Busy Status
Before you send a meeting request, you can check an attendee's calendar to see when the attendee is available. The IAddressee.GetFreeBusy method returns a string of numbers that indicate the attendee's availability for a requested period of time.
Each number in the free/busy string represents an interval of time (every ½ hour in this example). Free time returns 0, Tentative returns 1, Busy returns 2, and Out of Office (OOF) returns 3. If appointments overlap, the highest number is returned. If no free/busy data is available for the interval, the value 4 is returned.
The following figure shows part of an attendee's calendar and the corresponding free/busy string.
The free/busy string for a part of an attendee's calendar
To get an attendee's free/busy status for a specific time, you can create an Addressee object and execute the IAddressee.GetFreeBusy method. You can also get the free/busy status for longer intervals and parse the string to find times the attendee is free.
Note You must first call the IAddressee.CheckName method and resolve the addressee before you can use the IAddressee.GetFreeBusy method.
Note An automated process in Microsoft® Exchange Server 2003 periodically updates the free/busy status of users. Microsoft Outlook® updates the free/busy status of Outlook users. Collaboration Data Objects (CDO) synchronizes the Outlook free/busy cache with free/busy information from CDO clients. The free/busy status is not updated immediately when a meeting is added to a user's calendar. By default, three months' worth of free/busy status is maintained in a system folder in the Exchange store.
This topic contains Microsoft Visual Basic®, Microsoft Visual C++®, Microsoft C#, and Visual Basic .NET code examples.
Visual Basic
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(strUserUPN As String, dtStartDate As Date, dtEndDate As Date, Interval As Integer) As String
Dim iAddr As New CDO.Addressee
Dim freebusy As String
Dim Info As New ADSystemInfo
iAddr.EmailAddress = strUserUPN
If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
' handle error
End If
'Get the free/busy status in Interval minute intervals from dtStartDate to dtEndDate
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
GetFreeBusyString = freebusy
End Function
C++
The following example returns the free/busy status of the specified user:
/*
Assume that the following paths are in your
INCLUDE path.
%CommonProgramFiles%\system\ado
%CommonProgramFiles%\microsoft shared\cdo
*/
#import <msado15.dll> no_namespace
#import <cdoex.dll> no_namespace
#include <iostream.h>
// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
bstr_t getFreeBusyString( const bstr_t& userUPN, const bstr_t& domainDNSName, DATE startDate, DATE endDate, long Interval) {
IAddresseePtr iAddr(__uuidof(Addressee));
iAddr->EmailAddress = userUPN;
if(iAddr->CheckName(bstr_t("LDAP://") + domainDNSName, bstr_t(), bstr_t()) == VARIANT_FALSE) {
cerr << "Error looking up name!" << endl;
_com_issue_error(E_FAIL);
}
//Get the free/busy status in Interval minute intervals from startDate to endDate
return iAddr->GetFreeBusy(startDate, endDate, Interval, bstr_t(), bstr_t(), bstr_t(), bstr_t());
}
C#
The following example returns the free/busy status of the specified user:
// Reference to Microsoft ActiveX Data Objects 2.5 Library
// Reference to Microsoft CDO for Exchange 2000 Library
// Reference to Active DS Type Library
// Note: It is recommended that all input parameters be validated when they are
// first obtained from the user or user interface.
static string GetFreeBusyString(string strUserUPN, DateTime dtStartDate,
DateTime dtEndDate, int Interval)
{
try
{
// Variables.
CDO.Addressee iAddr = new CDO.Addressee();
string freebusy;
ActiveDs.ADSystemInfo Info = new ActiveDs.ADSystemInfo();
iAddr.EmailAddress = strUserUPN;
if (!(iAddr.CheckName("LDAP://" + Info.DomainDNSName, "", "")))
throw new System.Exception("Error occured!");
// Get the free/busy status in Interval minute
// intervals from dtStartDate to dtEndDate.
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate,
Interval, "", "", "", "");
return freebusy;
}
catch (Exception err)
{
Console.WriteLine(err.ToString());
return "";
}
}
Visual Basic .NET
The following example returns the free/busy status of the specified user:
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Library
' Reference to Active DS Type Library
' Note: It is recommended that all input parameters be validated when they are
' first obtained from the user or user interface.
Function GetFreeBusyString(ByVal strUserUPN As String, ByVal dtStartDate As Date, _
ByVal dtEndDate As Date, ByVal Interval As Integer) As String
Try
' Variables.
Dim iAddr As New CDO.Addressee()
Dim freebusy As String
Dim Info As New ActiveDs.ADSystemInfo()
iAddr.EmailAddress = strUserUPN
If Not iAddr.CheckName("LDAP://" & Info.DomainDNSName) Then
Throw New System.Exception("Error occured!")
End If
' Get the free/busy status in Interval minute intervals
' from dtStartDate to dtEndDate.
freebusy = iAddr.GetFreeBusy(dtStartDate, dtEndDate, Interval)
GetFreeBusyString = freebusy
Catch err As Exception
Console.WriteLine(err.ToString())
GetFreeBusyString = ""
End Try
End Function

Resources