Grails URL mapping gives 404 - grails

This is making me crazy: even though I was sure I have defined this custom mapping correctly, it keeps 404ing.
The resource is nested: a publisher has many channels, a channel belongs to a publisher.
I am trying to make an AJAX call that invokes the getMostRecentURLsWithoutChannels function in the Channel controller.
The desired URL format is /publishers/1009303/channels/getMostRecentURLsWithoutChannels
From UrlMappings.groovy:
"/publishers"(resources: 'publisher') {
"/configurations"(resources: "configuration")
"/metadatas"(resources: "metadata")
"/xpaths"(resources: "xpath")
"/channels"(resources: "channel")
"/crawlrequest"(resources: "crawlRequest")
}
"/publishers/${publisherId}/channels/getMostRecentURLsWithoutChannels"(controller: "channel", action: "getMostRecentURLsWithoutChannels", method: "GET")
The UrlMappingsReport shows:
Controller: channel
| GET | /publishers/${publisherId}/channels | Action: index |
| GET | /publishers/${publisherId}/channels/create | Action: create |
| POST | /publishers/${publisherId}/channels | Action: save |
| GET | /publishers/${publisherId}/channels/${id} | Action: show |
| GET | /publishers/${publisherId}/channels/${id}/edit | Action: edit |
| PUT | /publishers/${publisherId}/channels/${id} | Action: update |
| PATCH | /publishers/${publisherId}/channels/${id} | Action: patch |
| DELETE | /publishers/${publisherId}/channels/${id} | Action: delete |
| GET | /publishers/*/channels/getUrlsForChannel | Action: getUrlsForChannel |
| GET | /publishers/${publisherId}/channels/getMostRecentURLsWithoutChannels | Action: getMostRecentURLsWithoutChannels
Moving the custom mapping above or below the general publisher/channel block has no effect.
Even the createLink tag correctly creates the URL:
<g:createLink resource="publisher/channel" publisherId="${params.publisherId}" action="getMostRecentURLsWithoutChannels" />
results in
https://localhost:8443/publishers/1009303/channels/getMostRecentURLsWithoutChannels
The function in the controller is defined as:
def getMostRecentURLsWithoutChannels(Integer pub) {..}
What am I missing?

Related

Using KQL 'let' to combine two queries in the same table

I am trying to learn KQL and had a query where I wanted to take 2 values from Windows Event codes 4624 (login) and 4634 (logout) and return them for different scenarios I'm still trying to build.
But primarily I would just like to be able to return the values in a table (print or project?)
let login = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4624'
| project loginTime = TimeGenerated;
let logout = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4634'
| project logoutTime = TimeGenerated;
print login
The error I am getting is "'project' operator: Failed to resolve scalar expression named 'login'"
What I would have hoped to see is:
loginTime | logoutTime
----------------------------------------------
01/02/2021 18:46:30 | 01/02/2021 18:45:45
01/02/2021 18:47:30 | 01/02/2021 18:47:45
01/02/2021 18:48:30 | 01/02/2021 18:48:45
Would a join be better? It is in the same table (SecurityEvent), so I thought it would be possible to do it this way?
The dataset is from the MS provided Azure portal: https://portal.azure.com/#blade/Microsoft_Azure_Monitoring_Logs/DemoLogsBlade
Thanks for the help!
The problem is that "login" is a table type but print is expecting a scalar type.
let login = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4624'
| project loginTime = TimeGenerated;
let logout = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4634'
| project logoutTime = TimeGenerated;
print toscalar (login)
As to the result you are trying to get, I think this might be what you need:
Updated to improve clarity/perf
let login = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4624'
| project TargetLogonId, loginTime = TimeGenerated;
let logout = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4634'
| project TargetLogonId, logoutTime = TimeGenerated;
login
| join kind=leftouter logout on TargetLogonId
| project loginTime, logoutTime
I added some changes that encompass #GenericUser and #Slavik-N suggested and brings out the information that I was looking to calculate:
let login = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4624'
| where AccountType == 'User'
| project Computer,Account ,TargetLogonId, loginTime = TimeGenerated;
let logout = SecurityEvent
| where TimeGenerated > ago(1h)
| where EventID == '4634'
| where AccountType == 'User'
| project Computer,Account,TargetLogonId, logoutTime = TimeGenerated;
login
| join kind=inner logout on TargetLogonId
| project Computer,Account,loginTime, logoutTime, minute = datetime_diff('minute',logoutTime,loginTime)
| where minute >0
| sort by minute desc

Parse log for Phone number and BYE via powershell

I need to parse phone numbers from a log file (which is a .txt).
I need to find the phone number along with the timestamp and date and then the corresponding terminated request (which is when the caller hangs up) for that phone number. All calls into the system are iniated with DNAME and ended with TERMINATED.
I've used the select-string command but i cant filter the data effectively
the data is as follows :
13/08/2015 08:57:46:849 | L:4831.1[Line:10003<<XXXXXXXXXX]: Updated OutCID:'Conference_Call' and DNName: 'CALLER '
13/08/2015 09:00:42:118 | Leg L:4839.1[Line:10003<<XXXXXXXXXX] is terminated: Cause: BYE from 66.23.190.100:5060
all phone numbers have been replaced by XXXXXXXX for safety.
Does anyone know of a more powerful command to do this?
more data
13/08/2015 08:55:27:554 | Session 1230943 of leg L:4820.1[Line:10003<<180012334545] is confirmed
13/08/2015 08:55:49:766 | Answer to offerer immediateily, other party (L:4820.1[Line:10003<<180012334545]) doesn't support re-invite
13/08/2015 08:55:49:972 | L:4820.1[Line:10003<<18001234545]: Updated OutCID: 'Conference_Call' and DNName: 'Joe Brown '
13/08/2015 08:55:49:972 | L:4820.1[Line:10003<<180012334545]: Target refresh is not possible: Line:10003<<18001334545 doesn't support re-INVITE
13/08/2015 08:55:49:972 | [CM503010]: Call(C:4820): Making route(s) from Line:10003<<18001334545 to <sip:811#127.0.0.1:5060>
13/08/2015 08:55:49:972 | [Flow] Call(C:4820): has built target endpoint: Ivr:811 for call from L:4820.1[Line:10003<<191944345740]
13/08/2015 08:55:49:972 | [CM503004]: Call(C:4820): Route 1: from L:4820.1[Line:10003<<18001233545] to T:Ivr:811#[Dev:sip:811#127.0.0.1:40600;rinstance=19fdaa2fa620113c]
13/08/2015 08:55:49:972 | [CM503027]: Call(C:4820): From: Line:10003<<18001334545 ("Glen Peaks " <sip:180012334545#98.100.70.194:5060>) to T:Ivr:811#[Dev:sip:811#127.0.0.1:40600;rinstance=19fdaa2fa620113c]
13/08/2015 08:55:49:972 | [Flow] Call(C:4820): making call from L:4820.1[Line:10003<<18001233545] to T:Ivr:811#[Dev:sip:811#127.0.0.1:40600;rinstance=19fdaa2fa620113c]
13/08/2015 08:55:50:027 | [CM503025]: Call(C:4820): Calling T:Ivr:811#[Dev:sip:811#127.0.0.1:40600;rinstance=19fdaa2fa620113c] for L:4820.1[Line:10003<<180012334545]
13/08/2015 08:55:50:181 | L:4820.3[Ivr:811] has joined to L:4820.1[Line:10003<<18001234545]
13/08/2015 08:55:50:181 | L:4820.1[Line:10003<<19914345740]: Terminating targets, reason: SIP ;cause=200 ;text="Call completed elsewhere"
Your question is not clear enough, though regarding the TimeStamp and Phone number you can use this:
$Array = #()
$text = cat C:\Test.txt
$TimeStamp = "\d{2}\D\d{2}\D\d{4}\s\d{2}\D\d{2}\D\d{2}\D\d{3}"
$Number = "\d{10}"
foreach ($Line in $text)
{
$Result = "" | Select TimeStamp,Number
$Result.TimeStamp = $Line | select-string -Pattern $TimeStamp -AllMatches | % { $_.Matches } | % { $_.Value }
$result.Number = $Line | select-string -Pattern $Number -AllMatches | % { $_.Matches } | % { $_.Value }
$Array += $Result
}
Please provide more info for the CALLER,Terminated etc. so i can help you find the correct Regex

Swift: Could not find an overload for '|' that accepts the supplied arguments

Trying to incorporate Parse into a new Swift project.
When I get to this block:
logInViewController.fields = PFLogInFieldsUsernameAndPassword | PFLogInFieldsLogInButton | PFLogInFieldsSignUpButton | PFLogInFieldsPasswordForgotten
I'm getting this error in XCode 6:
Could not find an overload for '|' that accepts the supplied arguments
Anyone happen to know what's wrong with that syntax?
Use the .value then use the result to create a PFLogInFields instance:
logInViewController.fields = PFLogInFields(PFLogInFieldsUsernameAndPassword.value
| PFLogInFieldsLogInButton.value)
Timothy's answer is right but it is better to correct the code with Swift's update.
logInViewController.fields = PFLogInFields(rawValue:
PFLogInFieldsUsernameAndPassword.rawValue |
PFLogInFieldsLogInButton.rawValue)
Second way:
You can use operator overloading for shorter code:
func +=(inout slf: PFLogInFields,other: PFLogInFields)-> PFLogInFields{
slf = PFLogInFields(rawValue: slf.rawValue | other.rawValue)!
}
func +(a: PFLogInFields, b: PFLogInFields)-> PFLogInFields{
return PFLogInFields(rawValue: a.rawValue | b.rawValue)!
}
And further:
logInViewController.fields = .UsernameAndPassword + .LogInButton
or
logInViewController.fields = .UsernameAndPassword
logInViewController.fields += .LogInButton
In Swift 2 it seems that the accepted solution or other answers don't work.
I solved my problem by enclosing the PFLogInFields in an array. Everything seems to work just fine.
So instead of:
loginViewController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.PasswordForgotten | PFLogInFields.SignUpButton | PFLogInFields.Facebook | PFLogInFields.Twitter
I wrote:
loginViewController.fields = [PFLogInFields.UsernameAndPassword, PFLogInFields.LogInButton, PFLogInFields.PasswordForgotten, PFLogInFields.SignUpButton, PFLogInFields.Facebook, PFLogInFields.Twitter]
Seems this is a moving target, as none of the answers here seem to work anymore. At present I have to use this:
logInViewController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton

difference between hasmany belongsTo , namedQuery belongsTo and hasmany instantiation grails domain

In grails, I have two domain classes Question and QuestionOption.One question have many options.Each option has a question.
I went through 4 different scenario.
These scenarios has combination of instantiation-namedQuery , belongsTo-namedQuery , instantiation-hasMany and belongsTo-hasMany.
Scenario 1:
class Question
{
String quesText
static constraints={}
static namedQueries={
getAllQuestionOptions{question->
return QuestionOption.findAllWhere(question:question)
}
}
}
class QuestionOption
{
String optionText
Question question
static constraints={}
}
.
Scenario 2:
class Question
{
String quesText
static constraints={}
static namedQueries={
getAllQuestionOptions{question->
return QuestionOption.findAllWhere(question:question)
}
}
}
class QuestionOption
{
String optionText
static constraints={}
static belongsTo=[question:Question]
}
.
Scenario 3:
class Question
{
String quesText
static constraints={}
static hasMany=[questionOption:QuestionOption]
}
class QuestionOption
{
String optionText
Question question
static constraints={}
}
.
Scenario 4:
class Question
{
String quesText
static constraints={}
static hasMany=[questionOption:QuestionOption]
}
class QuestionOption
{
String optionText
static constraints={}
static belongsTo=[question:Question]
}
I used all these scenarios with mysql and all resulted with same schema
mysql> desc question;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| version | bigint(20) | NO | | NULL | |
| ques_text | varchar(255) | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
3 rows in set (0.00 sec)
mysql> desc question_option;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | bigint(20) | NO | PRI | NULL | auto_increment |
| version | bigint(20) | NO | | NULL | |
| option_text | varchar(255) | NO | | NULL | |
| question_id | bigint(20) | NO | MUL | NULL | |
+-------------+--------------+------+-----+---------+----------------+
What is difference between using these scenarios in the terms of cascading , unidirectional-bidirectional and aggregation-composition?
Bidirectional means when both entity knows about each other.Unidirectional means first entity know about second but reverse is not true.
To understand cascading I referred this: http://www.mkyong.com/hibernate/hibernate-cascade-example-save-update-delete-and-delete-orphan/ .
Please help
belongsTo and hasMany associations in Grails effect the cascading behavior when it relates to updating/deleting instances. It has no effect on the named queries or querying in general.

How to get a null value when using the head function with an empty list

I have a cypher query like this.
START dep=node:cities(city_code = "JGS"),
arr=node:cities(city_code = "XMN")
MATCH dep-[way:BRANCH2BRANCH_AIRWAY*0..1]->()-->arr
RETURN length(way), transfer.city_code,
extract(w in way: w.min_consume_time) AS consumeTime
The relationship named "way" is a optional one, so the property named "consumeTime" will be a empty list when the relationship "way" not exsit.
The query result is:
| 0 | "JGS" | [] |
| 1 | "SZX" | [3600] |
When I want to use the head function with the property "consumeTime", it return a error "Invalid query: head of empty list".
How can I get a result like this?
| 0 | "JGS" | null |
| 1 | "SZX" | 3600 |
This would be trivial with conditional expressions, which is something I think is important to add to Cypher: https://github.com/neo4j/community/issues/899
Here's a somewhat hacky query using reduce for you that requires 1.9-SNAPSHOT:
START dep=node:cities(city_code = "JGS"),
arr=node:cities(city_code = "XMN")
MATCH dep-[way:BRANCH2BRANCH_AIRWAY*0..1]->()-->arr
WITH length(way) as wayLength,
transfer.city_code as transferCityCode,
extract(w in way: w.min_consume_time) AS consumeTime
WITH wayLength,
transferCityCode,
consumeTime,
// reverse the consumeTime list, so that we can get the head from the end
reduce(acc=[], x in consumeTime: x + acc) reverseConsumeTime
RETURN wayLength,
transferCityCode,
consumeTime,
// return null if empty, else the end of the list
reduce(acc=null, x in reverseConsumeTime: x) as headOrNull;
This query could be improved a fair amount with the following syntax to reverse a collection:
reverse(coll) or conditional expressions to check for an empty list.

Resources