How to get name (uri) of all model files in project - xtext

In validator I would like to get uri of all model files.
I can get name only of current file (e.g myDsl1.mydsl) but I would like to get uri of other files too (e.g myDsl2.mydsl, myDsl3.mydsl).
Can this be done in validator or I should create new classes/methods for seeing this files?

You can access the Xtext index IResourceDescriptions via IResourceDescriptionsProvider. You can ask IResourceDescriptions for getAllResourceDescriptions which you may have to filter for project.
to use std visibility meachinsm check out IContainer.Manager with getVisibleContainers/getContainer and IContainer.getResourceDescriptions´. Check out DefaultGlobalScopeProvider` for sample usage.

Related

Do not replace existing file when uploading file with same name Microsoft Graph API

How can I prevent replacing the existing file with a new file which has the same name, when I upload file to one drive?
I am using PUT /me/drive/items/{parent-id}:/{filename}:/content docs end point.
I instead need to keep indexing (test.jpg, test (1).jpg) or, just like google drive does, add two files with the same name.
You can control this behavior using Instance Attributes, specifically the #microsoft.graph.conflictBehavior query parameter. There are three supported conflict behaviors; fail, replace (the default), and rename.
The conflict resolution behavior for actions that create a new item. You can use the values fail, replace, or rename. The default for PUT is replace. An item will never be returned with this annotation. Write-only.
In order to have it automatically rename the file, you add #microsoft.graph.conflictBehavior=rename as a query parameter to your URI.
PUT /me/drive/items/{parent-id}:/{filename}:/content?#microsoft.graph.conflictBehavior=rename

Generate URL of resources that are handled by Grails AssetPipeline

I need to access a local JSON file. Since Grails 2.4 implements the AssetPipeline plugin by default, I saved my local JSON file at:
/grails-app/assets/javascript/vendor/me/json/local.json
Now what I need is to generate a URL to this JSON file, to be used as a function parameter on my JavaScript's $.getJSON() . I've tried using:
var URL.local = ""${ raw(asset.assetPath(src: "local.json")) }";
but it generates an invalid link:
console.log(URL.local);
// prints /project/assets/local.json
// instead of /project/assets/vendor/me/json/local.json
I also encountered the same scenario with images that are handled by AssetPipeline1.9.9— that are supposed to be inserted dynamically on the page. How can I generate the URL pointing this resource? I know, I can always provide a static String for the URL, but it seems there would be a more proper solution.
EDIT
I was asked if I could move the local JSON file directly under the assets/javascript root directory instead of placing it under a subdirectory to for an easier solution. I prefer not to, for organization purposes.
Have you tried asset.assetPath(src: "/me/json/local.json")
The assets plugin looks in all of the immediate children of assets/. Your local.json file would need to be placed in /project/assets/foo/ for your current code to pick it up.
Check out the relevant documentation here which contains an example.
The first level deep within the assets folder is simply used for organization purposes and can contain folders of any name you wish. File types also don't need to be in any specific folder. These folders are omitted from the URL mappings and relative path calculations.

Desire2Learn Valence API - spaces in file name

We're trying to pull files and folders from the locker, but the command (/d2l/api/le/(D2LVERSION: version)/locker/myLocker/(string: path)) doesn't like spaces in the file or folder name. It returns either Bad Request or Invalid Token depending on how we attempt to handle the spaces on our end (i.e. string replace with %20).
How would we retrieve files/folders with spaces in the name?
I can think of some possible problems you're encountering.
When you provide the API path to your D2LUserContext object, you need to pass in only the API path, with internal spaces, not escaped characters. So, a proper route to a file named test file name might look like this:
/d2l/api/le/1.0/locker/myLocker/firstFolderBelowRoot/test file name
to create the authenticated URL for this, you'd invoke
yourD2LUserContext.createAuthenticatedUri('/d2l/api/le/1.0/locker/myLocker/firstFolderBelowRoot/test file name', 'GET')
That would fashion an authenticated URL you can use to fetch that file named test file name from your locker. To fetch its containing folder:
yourD2LUserContext.createAuthenticatedUri('/d2l/api/le/1.0/locker/myLocker/firstFolderBelowRoot/', 'GET')
Note that when you want to identify a folder in the locker, the path parameter must end with a trailing slash. (If you're trying to fetch a folder, and you don't have the trailing slash, that might be a source of your issue.)
Once you have that URL, you'll need to use some sort of HTTP library to actually make the call. Our internal PHP devs have recommended using HttpRequest rather than cURL with PHP. Most notably, the URL you should make the call with should preserve the space in the file or folder name in the path component of the URL.
When I test against a 9.4.1 instance using the Python client to do fetches/puts from the locker, or to generate URLs using the user context object and then feeding those URLs into a browser, things seem to work fine. Testing against a 10.0.0 test instance using the Python client also seems to be working.

Grails process dynamic javascript (output from gsp) as a resource

I have a JS file that is included in my GSP template as follows:
<r:script type="text/javascript">
<g:render template="/javascript/common"/>
</r:script>
The /javascript/common outputs some dynamic JS e.g. pre-populates lists client side. It's dynamic per server restart i.e. it doesn't need to be generated per request, but rather more commonly on redeployment.
I'm wondering how I can process it as a resource using the resource plugin and get the ability to minify it and compress it etc.
There may be times where it would need to be refreshed. Is it possible to support refreshing it in a similar fashion to other resources i.e. when the underlying file is modified the plugin reloads it.
thanks ...
The best way to ensure it cooperates with the resource plugin would be to create a custom ResourceMapper
Oversimplified version:
Create a file with ResourceMapper.groovy as the file suffix, in the grails-app/resourceMappers folder.
Decorate the class using def phase = MapperPhase.GENERATION
Implement def map(resource, config) {} to generate your resource when requested.
Your custom mapper will run once per deployment, then use the static generated file. All of the minify/compress, you're using will, of course, run after the GENERATION phase.
UPDATE: It does look like the Gsp Resources plugin #Ruben suggested would do what you're looking for. You can see the source for its custom mapper.

How to generate 2 Resource files in a single class in Blackberry 4.5?

I am creating a resource file using
ResourceBundle _resources = ResourceBundle.getBundle(BUNDLE_ID, BUNDLE_NAME);
Now i want to create another Resource file in that same class.
Can i do it in the same way like for first Resource file ?
The interface ResourceFile.java is an auto-generated file. Then how to view it ?
You need to edit the resource file (ResourceFile.rrc) in the BlackBerry JDE directly - from there you can add new key/value pairs. I don't think there's a way to iterate through all available keys in the code.

Resources