File upload and download from Filenet - filenet-p8

We are working on integration Dynamics CRM with Filenet. This requires support of the following two scenarios:
Upload a document in Filenet through web service and retrieve a unique URL for uploaded document from Filenet
Download document through unique URL of Filenet
Development platform is .NET.
Any ideas about the integration mechanism for same? Is there any webservice exposed by Filenet which we can consume for above 1 & 2 requirements?

The url's in filenet are always in a fixed format, so that's not difficult.
http://P8_client_server_name/application_name:port/getContent?objectStoreName={84A4A727-37E2-4994-B060-8531FAF75612}&objectType=document&id={559946a8-2007-4096-AC67-773A8540AE6}
So call the getContent page with the parameters opbjectstore name or ID, objecttype and the id of the document.
Here is an article about the format of the url's it should help you for the downloading part.
About the uploading,
Here are some API samples about sorting a document in the content engine. With the Id created were you can construct the url to return to the client.

In addition to the previous response, for downloading you can also construct a URL for IBM Content Navigator like this
http://myserver.mycompany.com:9080/navigator/bookmark.jsp?desktop=AccountsPayable&repositoryId=AP_P8_System&docid=30dd879c-ee2f-11db-8314-0800200c9a66&template_name=APtemplate&version=released
where
desktop Specifies which desktop to log in to.​ Specify the ID that is
displayed for the desktop in the ID column on the Desktops tab in the
administration tool. Format: desktop=desktop_ID
repositoryId Specifies the server to log in to.​ Specify the ID that
is displayed for the server in the ID column on the Repositories tab
in the administration tool. Format: repositoryId=repository_ID
docid The system-generated identification number for the document.
Uses the template_name value as the prefix to this folder ID. Format:
docid=document_ID
template_name Document, Folder, or the name of the custom document
class or item type. Format: template_name=template_name
version current, released, or a specific version number. Format:
version=version_number
vsld The IBM FileNet® P8 version series object, which is the Globally
Unique Identifier (GUID), that is associated with the document.
Format: vsld=GUID_number
Using Navigator menu:
You can get URLs for documents or folders when you select the item and
click Actions > View link.

Related

Magento REST API - How to determine the API base URL?

I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.
The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>

Magento REST API - "Specified request cannot be processed" Error [duplicate]

I'm running Magento 2.2.5 and was having trouble working out what the URL was for making API requests. For example to GET a list of countries I had seen the following syntax used:
/rest/default/V1/directory/countries
which has worked on some stores, but I was getting this error:
{
"message" : "Specified request cannot be processed.",
"trace" : null
}
I started playing around with the URL format and removed the "default" and used this instead:
/rest/V1/directory/countries
and the requests were then successful. How does one determine what the base URL to use for Magento REST API requests? I haven't been able to find this documented so far.
The syntax of Magento 2 Api is
http://<:host:>/rest/<:store_code:>/<:api_path:>
Here store_code can be any one of the "store view" of your Magento2 instance. You can get the store code in admin panel. You can use store_code to get information specific to that Store View via API. By default Magento2 installation comes with 1 website, 1 store & 1 store view (this store-view has code "default", in your case this might have changed hence you get the error).
The architecture can be understand with the help of image
Reference Image
Ref: https://docs.magento.com/m2/ce/user_guide/stores/websites-stores-views.html
When you specify store_code it checks information for that particular Store-View. If the specified store_code is not found in the database, Api returns "Specified request cannot be processed." message.
When you do not specify store_code it first finds default Website, then finds default Store for this Website & then finds default Store View Associated to this Store. And finally it returns information for this default Store-View. The association of default store & store-view can be changed from admin panel.
Reference Image
Hence the URL for API should be below in case you need store specific information. store_code can be set to all if you need information for all the stores.
http://<:host:>/rest/<:store_code:>/<:api_path:>

Exporting Sonarqube reports into Excel - based on major, minor and critical categories

Is there a way to export Sonarqube reports into Excel - based on major, minor and critical categories?
You can use the REST API, to query the data into JSON text and then export that JSON to a CSV file.
I used the command below to get a JSON response:
http://xxxxx.xx.xxxx.com:9000/api/issues/search?componentRoots=test_xxx_xx&statuses=OPEN,REOPENED&pageSize=500&pageIndex=1
Where componentRoots is the your sonar project name.
It gave all the issues in JSON and then I converted it in to a CSV.
The only way is to use the api/issues/search web service
Yes you can use the REST APIs provided with SonarQube to query. The documentation of APIs is also embedded into every Sonar instance as different versions expose different APIs.
We use Python for similar work as response will be in JSON and it will be easier to manipulate. Once you have arrived extracted issues of your liking, write them into .CSV or excel.
Link to web services will be in footer of Sonar Instance.
PS: Expanded answer to offset short-sighted answering. What is provided here is only abstract and not complete answer with query details.
Not recommended by community
With DB:- If you have been using Sonar for long and if you won't upgrade SQ too often you can choose to study table structure and understand how data is organised. We have done this too, but it gets messier with every passing upgrade (more inner queries). Cost of querying will be saved on bulk process of data as ES is not involved
Please try the following command to get all issues in JSON format. Then you may consider to parse output by using jason parser programs.
Replace "XXX:XXX" with Sonar Key defined in "sonar.projectKey" variable on "sonar-project.properties.txt" file
http://localhost:9000/api/issues/search?componentKeys=XXX:XXX
I used F12 developer tools to create the report. Here is step by step solution:
Before opening Sonar report, press F12 to open developer tools in the browser tab (Refer screenshot). Click on Network tab. Initially it'll be empty:
Open Sonar report in the same browser tab.
Now you have to select a request in URL column (Refer screenshot in point # 4). You've to select that request whose URL is of the format - https://sonar:8443/api/issues/search?. Base URL might be different depending upon the name of the server where you have hosted Sonar website.
Click on Response tab (Refer screenshot):
Copy the entire JSON data to clipboard. First press Ctrl + A and then Ctrl + C to copy the contents.
JSON data that you got is in below format:
Data of all the issues is present inside issues key. It is of array type as it contains a list of issues. Paste the entire JSON data into any notepad editor and get the value of issues node. A sample issues node data is shown below:
[
{
"key":"AYMBNpviy48WWZHdsU1Z"
,"rule":"OWASP:UsingComponentWithKnownVulnerability"
,"severity":"MAJOR"
,"component":"B91661CE-50F8-45CB-8F54-29CD044EF32D"
,"project":"B91661CE-50F8-45CB-8F54-29CD044EF32D"
,"flows":[]
,"status":"OPEN"
,"message":"Filename: jquery-ui-1.10.3.custom.js | Reference: CVE-2021-41184 | CVSS Score: 6.1 | Category: CWE-79 | jQuery-UI is the official jQuery user interface library. Prior to version 1.13.0, accepting the value of the `of` option of the `.position()` util from untrusted sources may execute untrusted code. The issue is fixed in jQuery UI 1.13.0. Any string value passed to the `of` option is now treated as a CSS selector. A workaround is to not accept the value of the `of` option from untrusted sources."
,"author":""
,"tags":["cve","cwe","cwe-937","owasp-a9","vulnerability"]
,"transitions":["confirm"]
,"actions":["set_tags","comment","assign"]
,"comments":[]
,"creationDate":"2022-08-18T06:35:49+0100"
,"updateDate":"2022-08-18T06:35:49+0100"
,"type":"VULNERABILITY"
,"branch":"sonarqubepr"
,"scope":"MAIN"
,"quickFixAvailable":false
},
{
"key":"AYMBNpviy48WWZHdsU1_"
,"rule":"OWASP:UsingComponentWithKnownVulnerability"
,"severity":"MAJOR"
,"component":"B91661CE-50F8-45CB-8F54-29CD044EF32D"
,"project":"B91661CE-50F8-45CB-8F54-29CD044EF32D"
,"flows":[]
,"status":"OPEN"
,"message":"Filename: jquery.ui.datepicker-ml.min.js | Reference: CVE-2021-41183 | CVSS Score: 6.1 | Category: CWE-79 | jQuery-UI is the official jQuery user interface library. Prior to version 1.13.0, accepting the value of various `*Text` options of the Datepicker widget from untrusted sources may execute untrusted code. The issue is fixed in jQuery UI 1.13.0. The values passed to various `*Text` options are now always treated as pure text, not HTML. A workaround is to not accept the value of the `*Text` options from untrusted sources."
,"author":""
,"tags":["cve","cwe","cwe-937","owasp-a9","vulnerability"]
,"transitions":["confirm"]
,"actions":["set_tags","comment","assign"]
,"comments":[]
,"creationDate":"2022-08-18T06:35:49+0100"
,"updateDate":"2022-08-18T06:35:49+0100"
,"type":"VULNERABILITY"
,"branch":"sonarqubepr"
,"scope":"MAIN"
,"quickFixAvailable":false
}
]
The JSON array data obtained in previous step is of real use. Convert this JSON array data into an EXCEL file using any online converter. I used the following website - https://www.convertcsv.com/json-to-csv.htm
What if my report has more than one page?
Sonar loads 100 records per page. To get the next page you've to click on Show More button at the bottom:
Every time you click on the Show More button, a new request goes to the Sonar server which will show up in the F12 developer tool's Network tab. So for all subsequent pages, repeat same set of steps to create a new Excel sheet per page. Then merge all the Excel sheets manually to create single master report.
Note: While merging the Excel files, remember that every Excel file will have a header row at the top. While merging the files, you'll have to keep the header row from from the first Excel sheet and ignore from the rest.

how to retrieve select option ids and values via the web api

I'm using the api/data/v8.0 API endpoint of a microsoft crm 2016 and I can retrieve and update a specific entity using GET and PATCH on api/data/v8.0/accounts(063e4c86-e7f0-e511-93f7-123456bb6ce7).
That entity has a property called jobtypecode (I can see that on the JSON response of the GET) and on the front end of the CRM the possible values are the following (I retrieved them using dev tools by inspecting that html select):
721874717 Full Time
721874719 Part Time
721874713 Academic
721874714 Other
How can I retrieve those values via the API?
I tried using api/data/v8.0/GlobalOptionSetDefinitions and various combinations of api/data/v8.0/EntityDefinitions but no luck.
You can use EntityDefinitions with the MetadataId of account, add a filter to only get the optionset you want.
EntityDefinitions(70816501-edb9-4740-a16c-6a5efbc05d84)/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet
Source: https://msdn.microsoft.com/en-us/library/mt607522.aspx#bkmk_queryAttributes

Programatically retrieve an attachment stored on a note on a CRM 4.0 entity

How would you suggest working with files that is stored on the note of a entity in Crm. Could you write a generic method that will enable you to access any type of file? Or would it be better to have a method for dealing with each type of file?
For example, we are going to be saving a mix of swf files and xml files on the entity, so would it make sense to have a method each for example:
GetXmlFilesOnAccount(accountid)
GetSwfFilesOnAccount(accountid)
When you upload an attachment to CRM the mimetype is also saved as part of the record information.
The following link contains a nice example of how to download the attachemt using a single method. http://crmscape.blogspot.com/2009/10/ms-crm-40-sending-attachments-to.html
The post is missing the actual query needed to retrieve the annotations but you can tell what columns are required from the method signature.
My suggestion using your methods:
* GetXmlFilesOnAccount(accountid)
* GetSwfFilesOnAccount(accountid)
Retrieve account activitypointers by regardingobjectid(in your case accountid guid)
Loop through returned activitypointers
Get attachments for each activitypointer (activitypointer.activityid = activitymimeattachment.activityid)
Store attachments (disk, etc)
You don't even need two methods. You can retrieve all attachment file types for a given note (annotation) with a single method.
Hope this helps.
I recently started an Open Source Project on CodePlex to accomplish exactly that. Feel free to check out the Project's Web Page at:
http://crmattachdownload.codeplex.com/
You can also view the source code under the "Source Code" tab of that same page.
Pete

Resources