Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No error handling when creating a PageAsset that uses a URL that is already in use. #15951

Closed
fabrizzio-dotCMS opened this issue Feb 1, 2019 · 6 comments

Comments

Projects
5 participants
@fabrizzio-dotCMS
Copy link
Contributor

commented Feb 1, 2019

Right now when you attempt to create a PageAsset on the SYSTEM FOLDER using a URL that is already in use you won't get any Error message. The Content-Edit Dialog will simply close without a warning. And you'll see an exception in your logs like :

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: 
Duplicate entry '/-advanced-container-2-48190c8c-42c4-46af-8d1a-0cd5db894797' for key 'parent_path'
Caused by: com.dotmarketing.exception.DotDataException: Duplicate entry '/-advanced-container-2-48190c8c-42c4-46af-8d1a-0cd5db894797' for key 'parent_path'{
  "SQL": ["INSERT INTO identifier (parent_path,asset_name,host_inode,asset_type,syspublish_date,sysexpire_date,id) values (?,?,?,?,?,?,?)"],
  "maxRows": [-1],
  "offest": [0],
  "params": [
    "/",
    "advanced-container-2",
    "48190c8c-42c4-46af-8d1a-0cd5db894797",
    "contentlet",
    null,
    null,
    "9737c716-8a65-41ab-bade-86cb164a9aae"
  ]
}

A similar problem was already solved for FileAssets. Apparently, PageAssets use a different execution path.

Expected Behavior

You should get a dialog warning you about another existing PageAsset using that URL

Current Behavior

When you hit save the Content Edit Dialog goes away without warning the user about the issue.

Steps to Reproduce (for bugs)

On content Search :

  1. Create a new content of type PageAsset input a title like "advanced + page - 1" then Save
  2. Create another PageAsset and input again a title like "advanced + page - 1" then Save

The second attempt will generate a url equal to the one used to save the first page.

@jgambarios jgambarios added this to the Cody Current milestone Feb 1, 2019

@wezell

This comment has been minimized.

Copy link
Contributor

commented Feb 5, 2019

This check needs to happen in the validation method of the ContentletAPI not the ContentletWebAPIImpl

@wezell

This comment has been minimized.

Copy link
Contributor

commented Feb 5, 2019

this is what I am seeing:

15:33:03.824  ERROR ajax.ContentletAjax - Another Page with the same URL already exists in this folder
com.dotmarketing.exception.DotRuntimeException: Another Page with the same URL already exists in this folder
	at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl._saveWebAsset(ContentletWebAPIImpl.java:483) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl.saveContent_aroundBody0(ContentletWebAPIImpl.java:138) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl$AjcClosure1.run(ContentletWebAPIImpl.java:1) ~[classes/:?]
	at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149) ~[aspectjrt-1.8.10.jar:?]
	at com.dotcms.aspects.aspectj.AspectJDelegateMethodInvocation.proceed(AspectJDelegateMethodInvocation.java:43) ~[classes/:?]
	at com.dotmarketing.db.LocalTransaction.wrapReturnWithListeners(LocalTransaction.java:40) ~[classes/:?]
	at com.dotcms.aspects.interceptors.WrapInTransactionMethodInterceptor.invoke(WrapInTransactionMethodInterceptor.java:23) ~[classes/:?]
	at com.dotcms.aspects.aspectj.WrapInTransactionAspect.invoke(WrapInTransactionAspect.java:41) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.business.web.ContentletWebAPIImpl.saveContent(ContentletWebAPIImpl.java:112) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.ajax.ContentletAjax.saveContent_aroundBody14(ContentletAjax.java:1513) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.ajax.ContentletAjax$AjcClosure15.run(ContentletAjax.java:1) ~[classes/:?]
	at org.aspectj.runtime.reflect.JoinPointImpl.proceed(JoinPointImpl.java:149) ~[aspectjrt-1.8.10.jar:?]
	at com.dotcms.aspects.aspectj.AspectJDelegateMethodInvocation.proceed(AspectJDelegateMethodInvocation.java:43) ~[classes/:?]
	at com.dotcms.aspects.interceptors.CloseDBMethodInterceptor.invoke(CloseDBMethodInterceptor.java:34) ~[classes/:?]
	at com.dotcms.aspects.aspectj.CloseDBAspect.invoke(CloseDBAspect.java:42) ~[classes/:?]
	at com.dotmarketing.portlets.contentlet.ajax.ContentletAjax.saveContent(ContentletAjax.java:1337) ~[classes/:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_162]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_162]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_162]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_162]
@fabrizzio-dotCMS

This comment has been minimized.

Copy link
Contributor Author

commented Feb 5, 2019

duplicate-url-error-not-handled

@wezell

This comment has been minimized.

Copy link
Contributor

commented Feb 6, 2019

PR: #15986

@bryanboza

This comment has been minimized.

Copy link
Contributor

commented Feb 22, 2019

Now we catch the exception, and we are not allowing to create the page, also show a notification at UI level, but we don't need the complete stack trace in the log since we catch the exception. Maybe we need print just an error or WARN, but just one line

@bryanboza bryanboza moved this from CODY to In Review in QA Feb 22, 2019

@wezell

This comment has been minimized.

Copy link
Contributor

commented Mar 6, 2019

Will work on that here: #16165

@wezell wezell closed this Mar 6, 2019

@bryanboza bryanboza moved this from In Review to Done in QA Mar 12, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.