How to dynamically create ressource with attribute? - coap

Context
I'm trying to dynamically create and access multiple CoAP ressources on the same server.
Basically what is would like is something like get coap://ip/ressource/* and get all the data of ressource/1 ressource/n
Linked subject
I found the following
CoAP: Group similar resources under one
"what's left is that you create a /TIME/ resource (the slash at the end does matter) and announce it in .well-known/core as ;if="core.b"."
Problem
I don't know how i can create a ressource with specific attributes from client
Experiment with libcoap
coap-client -m put coap://ip/ressource;if="core.b" doesn't return error but attributes is not created (used copper)

That's entirely up to the server. Are you writing the server (if so, using which framework?) or just trying to make an existing server (if so, which?) behave as you like?

Related

Is it possible for Tampermonkey to share one storage on different websites?

Similar to this, but has more details.
"share"ing is expected to be done by one script.
"storage" is which GM_{g,s}etValue use.
"different websites" are those which have different origins.
My scheme now:
On website A, I insert an iframe of site B, and synchronize storage by postMessage.
Information I've got:
From this, it seems that Tampermonkey used to support share data cross-originly.
As mentioned by wOxxOm, in order for 2 domains to share data via GM storage API, the script must run on both e.g. via #match.
However, in Tampermonkey the domains will get access to the data at the time script was injected.
Update: As pointed out by wOxxOm, "Both Tampermonkey/Violentmonkey provide real-time access to the real values. They do it by propagating the change to all tabs/frames where this script instance runs."
You can also use GM_addValueChangeListener() to listen to changes to the storage.
GM_addValueChangeListener()
Adds a change listener to the storage and returns the listener ID.
'name' is the name of the observed variable.
The 'remote' argument of the callback function shows whether this value was modified from the instance of another tab (true) or within this script instance (false).
Therefore this functionality can be used by scripts of different browser tabs to communicate with each other.
Note: In Greasemonkey & FireMonkey, the asynchronous GM.getValue() would always get the current up-to-date data.

Error issuing part using Maximo integration framework MXINVISSUE

We are upgrading from Maximo 7.5 to 7.6.1. Our web service that uses MXINVISSUEInterface is throwing an exception when we try to issue a part that is marked as a spare part and the work order has an asset. The exception says "BMXAA4195 - A value is required for the Organization field on the SPAREOBJECT object." The part is not in the SPAREPART table for the asset so it is trying to add it, but for some reason the ORGID is not populated from the MXINVISSUE_MATUSETRANSType object.
I re-generated the WSDL on the new server and rebuilt the solution, but after populate a new required field, I still get the same error.
Is there a system property that must be set. It works in 7.5 writing the record to MATUSETRANS and SPAREPART.
This sounds like a bug, so you might raise a Support Case with IBM about it. For a workaround until IBM releases a fix and you install said fix, consider the following options.
Can you set the Default Insert Site for the user using the web service?
Is it practical to put a Default Value on SPAREPART.ORGID?
Create an automation script called SPAREPART.NEW that will somehow figure out an ORGID to use. To "figure out", my first would be to check if mbo has an owner that has an ORGID and, assuming it does, use that.

Deploying my front end and detecting client location by IP address - which AWS service should handle this? Confused by my options

I'm still new to AWS and just following the documentation and asking questions here when I get stuck. Please excuse me if this question sounds really noobish.
So far, I've deployed the following:
EB to deploy my REST API
RDS to deploy my psql database
Lambda functions to handle things like authentication & sending JWTs, uploading images to S3, etc.
I have got my basic back end (no caching (just started learning about redis), etc. set up yet, just the bare bones so far) deployed.
I'm still developing my front end, and have not even thought about how I will be deploying it yet (probably another deployment on EB, since I am using universal react). I am just developing it locally but using my production env variables now so I am hitting my deployed API, etc.
One of the MAJOR things I have no idea on how to do is detecting incoming requests from client side to get the client's location by IP address. This is so that I can return the INITIAL results in your general location just like yelp, foursquare, etc. do when you go to to their sites.
For now, I am just building a web app on desktop so I just want to worry about getting the IP address to get the general area of the user. My use case is something similar to other sites you might have used which provides an INITIAL result set for things in your area (think foursquare or yelp).
Here are my questions:
What would be a good way to do this? I'm thinking of handling this in my front end react universal deployment since it will be a node server with rendered page caching. Is this a terrible idea? It would work something like
(1) request from client comes in
(2) get IP from request and lookup the IP location using some service (still not sure what I'm going to use, have found a few plus a nodejs library called node-geoip). Preferably, I can get the zip code since I am trying to save having to do so many queries by unique locations in my database, and instead return results in the zip code and the front end will show an initial map with the initial results in that zip code.
(3) return to client the rendered page with those location params if it exists, otherwise create it, send it, and cache it.
Is the above a really dumb idea? Maybe you have already done something like this, and could share your wisdom :)
Is there an AWS service which can already handle something like this for me? Perhaps there's some functionality which can already do this.
Thanks.
AGAIN - I apologize if this is long winded. I don't know anyone in real life who can help me and I feel alone :(. I appreciate the help you guys can provide.
There are two parts to this:
Getting the user's IP address. You mentioned you're using 'EB' - I presume you mean AWS ELB (Elastic Load Balancer)? If so, then you need to read the X-Forwarded-For HTTP header in your app code, since otherwise what you'll really detect is the ELB's IP address. X-Forwarded-For contains the user's real IP - or rather, the IP of the end-connection being made (there's no telling if this is really a VPN, Proxy or something else-- but it's as far as you can get with an IP.)
Querying an IP DB that can turn the addr into a location object. There are tons of libraries for you. Assuming you're using Node, you can use node-geoip as you mentioned. Or you can just search 'geoip service' on Google and find managed services, like Telize on Mashape. If you don't want to manage the DB lookup yourself or keep the thing up to date, then a managed service would help.
In either case, it's likely that you'll be doing asynchronous look-ups. In that case, you might want to use async/await to get the user's full object before injecting that into your React props and ultimately rendering it as a HTML string that's sent down to the client.
You could also use a library like redial to decorate your components with data requirements, and return a Promise you can await on to know when you're okay to render.
Since you probably want to enable client routing too (i.e. where the user can click on a route in their browser, and the server isn't touched at all), then you will probably need some way to retrieve the IP address/results based on that IP even when the server isn't involved in the initial render.
For that, you could write a REST service that retrieves the results. Or write a GraphQL back-end that gets the data. It doesn't matter how you write it, since the server will have access to the X-Forwarded-For header and can use that to retrieve the results and send back location-aware data.
FYI, I'm writing a React starter kit (called ReactNow) that uses rxjs for handling async streams. It's not ready yet, but it might help you figure out the code layout that would offer a balanced mix between rendering on the server, and writing universal code that requires some heavy lifting from the server.

Liferay model listener ordering

Following is my requirement :
Whenever site is created, with help of GroupListener we are adding some custom attributes to created site.
So assume that you are crating "Liferay Test" site then it will have some fix custom attribute "XYZ" with value set in GroupListeners onAfterCreate method.
I can see this value in custom fields under site settings.
Now based on this values, we are creating groups in another system(out of liferay, using webservices).
So far so good.
Whenever we are deleting the site we need to remove the equivalent groups from other system via web service.
But while deleting site, in GroupListener we are not able to retrieve the custom attributes.
On further debug by adding expando listener, I observed that Expando listeners are getting called first and then delete method of GroupLocalService/GroupListener.
And hence we are not able to delete the groups present in another system.
So I was wondering if we can have ordering defined for listeneres.
Note: Since we were not getting custom attributes in listeners we implemented GroupLocalServiceImpl and with this we are getting custom attributes in delete method on local environment but not on our stage environment which has clustering.
You shouldn't use the ModelListeners for this kind of change, rather create ServiceWrappers, e.g. wrap the interesting methods in GroupLocalService (for creation as well as deletion).
This will also enable you to react to failures to create records in your external system etc.

How to get web resource content?

My requirement is when selection of a web resource one HTML page should appear with the content of that web resource.
So I thought I will add a plugin which will get the content of a web resource and dynamically create a HTML page.
now the problems I am having:
1) when the plugin should fire. because it should fire on selection of any web resource, and didn't show web resource in entity list in VS project using developer's tool kit.
2) How I can get the GUID of that selected web resource to get the content.
please guide me how I can do this. Is there any alternate way to do this?
Thank you.
It's a bit unclear what you mean but if I got the nature of your problem correctly, this is the answer to your question.
You're not supposed to use a plugin at all. Since this is an operation on the user interface only, JavaScript is the way to go here. You want to dynamically create contents in a IFRAME component and display those to the user. You should implement onsomeevent method and connect the clicking to fire it.
Accessing web resources is not done by their guids but through their name. At least when trying to access cross frame data stored in such a resource. The name is something that you set yourself when you create or upload the resource to the server.
May be i am wrong about this question.
Using JavaScript, you can achieve this as well.
In JavaScript, access selected WebResource with their name, and you can get details of that WebResourse by making an ActiveXObject.
var JScriptWebResourceUrl = "..Path Of WebResource/jquery.1.4.4.min.js";
var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("GET", JScriptWebResourceUrl, false);
xmlHttp.send();
eval(xmlHttp.responseText);
Now, you can do what you want from here.
Thanks,
Anish

Resources