Quantcast
Channel: Alfresco Forums - Web Scripts
Viewing all 105 articles
Browse latest View live

safely crawl all documents via webscript

$
0
0

what i am trying to do is:

find all nodes in the repo and get their file size. also get all versions of the node and calculate the overall filesize of the node and its versions.

how can i safely crawl every document in the repository?

searchservice is going to hit the result-limit easily, even if i increase the limit, the searches wont return results.

by traversing recursively through the repository i also seem to fill up the solr caches

private staticvoid traverse(List<FileInfo> context){for(FileInfo node : context){if(node.isFolder()){
            traverse(fileFolderService.list(node.getNodeRef()));}else{// is file = do stuff}}}

... :44,186  INFO  [solr.component.AsyncBuildSuggestComponent][Suggestor-alfresco-1] Loaded suggester shingleBasedSuggestions, took 267411 ms
... :53,005  WARN  [cache.node.nodesTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.node.nodesTransactionalCache' is full (125000).
... :17,075  WARN  [cache.node.aspectsTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.node.aspectsTransactionalCache' is full (65000).
... :17,081  WARN  [cache.node.propertiesTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.node.propertiesTransactionalCache' is full (65000).
... :19,938  WARN  [alfresco.cache.contentUrlTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.contentUrlTransactionalCache' is full (65000).
... :19,991  WARN  [alfresco.cache.contentDataTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.contentDataTransactionalCache' is full (65000).
... :49,599  WARN  [org.alfresco.nodeOwnerTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.nodeOwnerTransactionalCache' is full (40000).
... :27,516  WARN  [cache.node.childByNameTransactionalCache][http-apr-8080-exec-1] Transactional update cache 'org.alfresco.cache.node.childByNameTransactionalCache' is full (65000).

i understand it is an antipattern to grab everything at once, but i don't know of any service/api that allows me to page the results into batches/pages,
please enlighten me :(

version: 5.0.c


CMIS webscript not found

$
0
0

Hello guys,

I've installed Alfresco Community 5.0, but I can't find CMIS service.

When I accessed http://127.0.0.1:8090/alfresco/service/cmis, I got the Error like this " The Web Script /alfresco/service/cmis has responded with a status of 404 - Not Found. "

Could someone help me?

Thank you

Clearing/Unsetting the value of a date property via REST API

$
0
0

Hi.

I'm developing a Java application that connects to Alfresco Community 4.2.

One of the functionalities involves setting and modifying a document's properties through /alfresco/service/api/metadata/

I create a JSONObject and set the value of each property, which works perfectly for all cases, except when trying to clear or unset the value of a Date property.

I tried sending "" (empty string) or null as the property's value, but when I check the metadata, the property has the same data as before.

Basically what I'm trying to do is replicate via REST API the behavior of the "None" button in the faces interface: ScreenShot

Is there a way to do that via WebScripts?

Thank you.

4.2

why my http://127.0.0.1:8080/alfresco/service/api/people returing blank people json object

$
0
0

I have list of user in my alfresco share, which i can access by logging to alfresco, but when i am accessing the list of people through ip given below.

//127.0.0.1:8080/alfresco/service/api/people

I am getting the below given output.

{
"people" : [
]
}

I tried re-installation the alfresco, but the problem is same all the time.

4.2.a

500- Internal Error when admin tries to unshare a file in users' private site

$
0
0

Hello people,

Alfresco community edition returns 500 internal error when trying to unshare a file which is in users' private site.

To reproduce:

1.User creates a private site
2.User creates a file
3.User shares it
4.A rest call to unshare this file with admin credentials returns

Failed to execute http://localhost:8080/alfresco/s/api/internal/shared/unshare/3uIfYLFlSlGIJXLURf2opg?alf_ticket=TICKET_0c51707f6775f7dd98c8977546c2c3edca996d48  {"status":{"code":500,"name":"Internal Error","description":"An error inside the HTTP server which prevented it from fulfilling the request."}, "message":"01250010 Wrapped Exception (with status template): null","exception":"org.springframework.extensions.webscripts.WebScriptException - 01250010 Wrapped Exception (with status template): null", "callstack":["","java.lang.NullPointerException","org.alfresco.repo.web.scripts.quickshare.UnshareContentDelete.executeImpl(UnshareContentDelete.java:96)","org.springframework.extensions.webscripts.DeclarativeWebScript.execute(DeclarativeWebScript.java:64)","org.alfresco.repo.web.scripts.RepositoryContainer$3.execute(RepositoryContainer.java:489)","org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:457)","org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:551)","org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:619)","org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:399)","org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:280)","org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:378)","org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)","org.springframework.extensions.webscripts.servlet.WebScriptServlet.service(WebScriptServlet.java:132)","javax.servlet.http.HttpServlet.service(HttpServlet.java:727)","org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)","org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)","org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)","org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)","org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)","org.alfresco.web.app.servlet.GlobalLocalizationFilter.doFilter(GlobalLocalizationFilter.java:61)","org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)","org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)","org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)","org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)","org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:504)","org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)","org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)","org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)","org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)","org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:421)","org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1074)","org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:611)","org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.doRun(AprEndpoint.java:2466)","org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:2455)","java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)","java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)","org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)","java.lang.Thread.run(Thread.java:745)","org.springframework.extensions.webscripts.WebScriptException: 01250010 Wrapped Exception (with status template): null","org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:1127)" ], "server":"Community v5.0.0 (d r99759-b2) schema 8,022","time":"Feb 25, 2016 3:23:43 PM"}

I think because admin is not a collaborator on the site, he doesn't have a role associated which causes the null pointer exception at UnshareContentDelete.java:96  if(role.equals(SiteModel.SITE_CONSUMER)|| role.equals(SiteModel.SITE_CONTRIBUTOR))

If admin is manually added as a collaborator to the site, the rest call succeeds.

I'm able to download the file with admin credentials, so the admin does have read access and should be able to unshare as per http://docs.alfresco.com/5.0/references/RESTful-QuickshareUnshareDelete.html. This makes me think the issue is at webscripts and not internal API.

Is there any other temporary quick fix for testing (making the admin a site manager, unsharing the file and removing?)

Thanks

5.0.d

use manage-permissions webscript on admin consol dashlet

$
0
0

Hello,
I am new with alfresco. I use the 5.0.d version. I want to add an admin console module that can use manage-permissions webscript. In fact i want to show manage-permissions in a div of the ftl of my new webscript. Is that possible? If yes how can i do it?
thanks :)

5.0.d

Not able to create site programmatically

$
0
0

Hi ,

I trying to create a site in alfresco share using a webscript in java and this i am doing with the help of below code:

HttpClient client =new HttpClient();  
		PostMethod  httpPost =new PostMethod ("http://localhost:8080/share/service/modules/create-site?authority="+username+"&alf_ticket="+alf_tkt);  
		 JSONObject site =new JSONObject();try{
			site.put("shortName","java_test");
			site.put("Visiblity","Public");
			site.put("sitePreset","site-dashboard");
			site.put("title","java_test");
			site.put("description","test");
			httpPost.setDoAuthentication(true);
			httpPost.setRequestHeader("Content-Type","application/json");
			httpPost.setRequestEntity(new StringRequestEntity(site.toString(),"application/json","UTF-8"));  int status1 = client.executeMethod(httpPost); if(status1 != HttpStatus.SC_OK){
			System.err.println("Method failed: "+ httpPost.getStatusLine());}   }catch(JSONException e1){// TODO Auto-generated catch block
			e1.printStackTrace();} 

It is giving me the error as HTTP/1.1 401 Unauthorized.

Please help me in this.

Regards,
Nancy

Cannot create new user with out of the box script

$
0
0

Hi Guys!

If I try to invoke org/alfresco/repository/person/people.post script to creat an user. It always invokes the GET version of this script instead of the POST version

I have used the following json string as body text:

{"userName":"maxthetestuser","firstName":"Max","lastName":"Testmann","email":"test@234.ch","password":"password123"}

Can somebody give me a hint?

Best regards
Kaffi

5.0

Cannot invoke webscript as normal user

$
0
0

Hi Guys!

I wrote a script which modifies data and copy it to a folder. As a admin it works without any problems but as normal user I get always an unauthorized exception. The webscript is a java backend script which is called via a custom front end.

I put my descriptor file below:

Modify content and copy it to a folder
Modify data
/api/modifications_script/mod_data_structure?file={file_nodeRef}&destination={destination_nodeRef}
extension
required
user

Do somebody have an idea?

Best regards
Kaffi

5.0

importing existing portal webapps

$
0
0

Hi there, I’ve spun up a Alfresco Community 4f so that the business people can do BPM and Doc management

We have an existing portal where we access some small number of webapps (mostly javascript pages that call out to various internal servers for data) — I can’t figure out where/how to add those into Alfresco, all of the integration talk seems to be about accessing Alfresco programmatically from other apps.

These apps would have nothing to do with Alfresco other than appearing as content within an Afresco site -- framed? portlet-ed?

I’ve been paging thru the posted extensions and found a dashclock portlet — is that the direction I need to go or are there others?

Many of the apps are AngularJS -- I hope that's not going to be a barrier to bringing them in.

Thanks
Al;

4.2.f

POST send and receive json

$
0
0

Hello guys i'm trying to send json on klient side and receive json on server side. Only things what im getting is null or undefined, i tried many ways here is the last and most promisng but still not functional. Here is the request from client side:

Alfresco.util.Ajax.request(
{
url: Alfresco.constants.PROXY_URI + "s/saveForm",
method: Alfresco.util.Ajax.POST,
requestContentType: "json",
dataObj:
{
site: Alfresco.constants.SITE,
dataValues: JSON.stringify(formDataArray),
submitType: "json"
},

successCallback:
{

scope: this
},
failureCallback:
{

scope: this
},
execScripts: true
});

Here is how should i receive json:
var jsonData = json.get("dataValues");

Im getting error that json is undefined but it should be defined. Anybody please tell me what im doing wrong ?

5.0.c
post

List all site roles of a user

$
0
0

Hello,

I'm trying to list all site roles (or preferably site groups) of a user.

I'm familiar with GET /alfresco/s/api/people/{userName}?groups=true to get the groups the user is a member of, but it doesn't return site groups such as GROUP_site_{sitename}_SiteContributor. Could I somehow modify this request to also get all site groups of the user?

Other request I have tried to use to solve this is GET /alfresco/s/api/people/{userid}/sites?size={pagesize?}&pos={position?}&roles={roles?} which lists sites the user is an explicit member of, but this doesn't return the exact member roles/groups of {userid}. Could I perhaps use the roles-parameter to find this out? I have learned that using roles=user I can get the site roles of the user making the request, but I want to find out the site roles of {userid}.

I can also get the user's role for a site by using GET /alfresco/s/api/sites/{shortname}/memberships/{authorityname}, but using this I would have to loop through all the sites to get the list of all site roles of a user, which doesn't seem a nice solution.

Is there a way to solve this problem?

Thanks

5.0

Parse webform data to pdf

$
0
0

Hi,

I've created a two-field webform and the attachment button to allow a document to be posted to Alfresco Community 5.0.d Repository as per the online tutorial we're all familiar with. It works great.

I have next created a webform with about 12 data fields. I would like to take these 12 pieces of information in the data fields and transfer (parse) them to a document with corresponding blank fields in my Alfresco repository. Not being the most fluent in Java, I’ve been unsuccessful in devising a strategy to do so.

can anyone out there offer some pointers about how I can accomplish this?

Thank you,
Frank

5.0.d

Using remote endpoint in repository script or custom action

$
0
0

Hi!

I'm new in Alfresco and I need exactly this: https://forums.alfresco.com/forum/developer-discussions/web-scripts/using-remote-endpoint-repository-not-share-webscript

How can I use the solution proposed by AFaust (http://bit.ly/1TQQnkQ) in version 5.1?

I tried create the file custom-web-context.xml on /opt/alfresco-community/tomcat/shared/classes/alfresco/extension/ with the following content but after restart the Alfresco I got "An error has occured in the Share component: /share/service/components/dashlets/my-sites".

Some help?!

custom-web-context.xml:

<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN 2.0//EN''http://www.springframework.org/dtd/spring-beans-2.0.dtd'> <beans><bean id="webscripts.container"class="org.alfresco.repo.web.scripts.TenantRepositoryContainer" parent="baseAlfrescoRepositoryContainer" init-method="setup"><property name="configService" ref="webscripts.config"/><property name="name"><value>Repository</value></property><property name="allowCallbacks"><value>true</value></property><property name="scriptObjects"><map merge="true"><entry key="paging"><ref bean="webscripts.js.paging"/></entry><entry key="remote"><ref bean="webscripts.script.remote"/></entry><entry key="cmis"><ref bean="webscripts.js.cmis.client"/></entry></map></property><property name="webScriptsRegistryCache" ref="webScriptsRegistryCache"/><!-- Use the time-limited transaction helper to keep request times to an acceptable duration --><property name="transactionService" ref="transactionService"/><!-- The transaction helper used to generate error responses must be unlimited --><property name="fallbackTransactionHelper" ref="retryingTransactionHelper"/><property name="authorityService" ref="AuthorityService"/><property name="repository" ref="repositoryHelper"/><property name="repositoryImageResolver" ref="webscripts.repo.imageresolver"/><property name="templateProcessorRegistry" ref="webscripts.repo.registry.templateprocessor"/><property name="scriptProcessorRegistry" ref="webscripts.repo.registry.scriptprocessor"/><property name="descriptorService" ref="DescriptorService"/><property name="tenantAdminService" ref="tenantAdminService"/><property name="encryptTempFiles" value="${webscripts.encryptTempFiles}"/><property name="tempDirectoryName" value="${webscripts.tempDirectoryName}"/><property name="memoryThreshold" value="${webscripts.memoryThreshold}"/><property name="maxContentSize" value="${webscripts.setMaxContentSize}"/></bean></beans>

The error:

An error has occured in the Share component:/share/service/components/dashlets/my-sites.It responded with a status of 500- Internal Error.Error Code Information:500- An error inside the HTTP server which prevented it from fulfilling the request.Error Message: 02170001 Failed to execute script 'classpath*:alfresco/site-webscripts/org/alfresco/components/dashlets/my-sites.get.js': 02170000 02170001 Failed during processing of IMAP server status configuration from Alfresco: 02170000 Unable to retrieve IMAP server status from Alfresco:404
Server: Alfresco Spring WebScripts - v5.8.0 schema 1.000
Time:17/03/201611:20:56
Your request could not be processed at this time. Please contact your system administrator for further information

Upload and Download a file

$
0
0

I need to upload and download a file from alfresco using a web application i have created..Intially i tried using a small java code for upload using upload webscript it worked well but i didnt get any proper code for downloading a file can any body help..
or what is the simple method for uploading and downloading a file from alfresco using a web apllication i have created

5.0.d

javascript reading aspect cm:attachments and also check the mimetype of some file and create from folder if plain/text

$
0
0

OK, the mimetype is working in my code so my problem is that I want to read attachment of my file, please help me doing that

var fileNames = space.children; function main(){for(i=0; i<fileNames.length; i++){
    logger.log(fileNames[i].properties.content.mimetype);if(fileNames[i].isDocument&&(fileNames[i].properties.content.mimetype).equals("text/plain")){//document.childAssocsvar fileAttachments = fileNames[i].assocs['cm:attachments'][1];
      logger.log(i+" - "+fileNames[i].assocs['cm:attachments']);}};/*
  for (i=0; i<fileAttachments.length; i++){
    logger.log("===================================================");
    logger.log(fileAttachments[i]);
  };
*/}
main();

jmx webscript in 4.0

$
0
0

Hello

I saw good code with https://github.com/Alfresco/alfresco-support-tools

but the problem as you can read using "jmx" in javascript is possible only for 4.2, but I would like to use this synthax

example --
var configurationBeans = jmx.queryMBeans("Alfresco:Category=*,Type=Configuration,*");
--

Do you know how is it possible to call methode from jmx in my web script ?

for example

http://www.noelshack.com/2016-16-1461333504-jmx.png

calling the method isAvailable and getting back "true"

thanks

4.0

Webscript to export nodes to Excel: cannot call getWriter() after getOutputStream()

$
0
0

Hello everybody,

I have created a Spring Surf presentation webscript that queries the Alfresco repository for some list of nodes, and then exports a selection of node properties to an Excel file, to be downloaded by the user.
The Excel is generated on-the-fly, without being saved to the repository, and it is being streamed directly to the browser.

I have used the following XML webscript description:

<webscript>
<shortname>ElasticSearch search and export as Excel</shortname>
<description>ElasticSearch search and export as Excel</description>
<url>/es/exportexcel</url>
<authentication>none</authentication>
<format default=""></format>
</webscript>

and the webscript looks like this:

public class PublicSearchExportExcelWebScript extends AbstractWebScript {@Override
	public void execute(WebScriptRequest req, WebScriptResponse res)throws IOException {
		res.setContentType("application/vnd.ms-excel");
		res.setHeader("Content-Disposition","attachment; filename=\"export.xls\"");
		Workbook wb =new HSSFWorkbook();//..... build Excel
		OutputStream contentOutputStream = res.getOutputStream();
		wb.write(contentOutputStream);}}

But whenever I try to download the Excel file by using this webscript, I get this error in the logs (even if the file is downloaded successfully):

ERROR [org.springframework.extensions.webscripts.AbstractRuntime] Exception from executeScript - redirecting to status template error: strict servlet API: cannot call getWriter() after getOutputStream()
java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
        at weblogic.servlet.internal.ServletResponseImpl.getWriter(ServletResponseImpl.java:324)
        at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:148)
        at org.springframework.extensions.webscripts.servlet.WebScriptServletResponse.getWriter(WebScriptServletResponse.java:198)
        at org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer.executeScript(LocalWebScriptRuntimeContainer.java:241)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:377)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:209)
        at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:716)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:647)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:552)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:844)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:280)
        at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:254)
        at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:136)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:341)
        at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:238)
        at weblogic.servlet.internal.RequestDispatcherImpl.invokeServlet(RequestDispatcherImpl.java:573)
        at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:272)
        at org.tuckey.web.filters.urlrewrite.NormalRewrittenUrl.doRewrite(NormalRewrittenUrl.java:213)
        at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:171)
        at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
        at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
        at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:381)
        at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:79)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3367)
        at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3333)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
        at weblogic.servlet.provider.WlsSubjectHandle.run(WlsSubjectHandle.java:57)
        at weblogic.servlet.internal.WebAppServletContext.doSecuredExecute(WebAppServletContext.java:2220)
        at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2146)
        at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2124)
        at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1564)
        at weblogic.servlet.provider.ContainerSupportProviderImpl$WlsRequestExecutor.run(ContainerSupportProviderImpl.java:254)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:295)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:254)  
ERROR org.springframework.extensions.webscripts.WebScriptException: 03260002 Internal error
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:335)
        at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
        at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)
        at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1060)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:798)
        Truncated. see log file for complete stacktrace
Caused By: java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
        at weblogic.servlet.internal.ServletResponseImpl.getWriter(ServletResponseImpl.java:324)
        at javax.servlet.ServletResponseWrapper.getWriter(ServletResponseWrapper.java:148)
        at org.springframework.extensions.webscripts.servlet.WebScriptServletResponse.getWriter(WebScriptServletResponse.java:198)
        at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:330)
        at org.springframework.extensions.webscripts.servlet.mvc.WebScriptView.renderMergedOutputModel(WebScriptView.java:104)
        Truncated. see log file for complete stacktrace

I investigated a bit inside the Spring Surf sources, and I identified that the error occurs at the following lines inside LocalWebScriptRuntimeContainer:

// call through to the parent container to perform the WebScript processing
        ExtensibilityModel extModel = openExtensibilityModel();super.executeScript(scriptReq, scriptRes, auth);
        closeExtensibilityModel(extModel, scriptRes.getWriter());

and then again inside AbstractRuntime when trying to redirect to the error status template:

String validTemplatePath = container.getTemplateProcessorRegistry().findValidTemplatePath(statusTemplate.getPath());
        TemplateProcessor statusProcessor = container.getTemplateProcessorRegistry().getTemplateProcessor(validTemplatePath);
        statusProcessor.process(validTemplatePath, statusModel, res.getWriter());

Is there a way for me to suppress the calling of getWriter after I have generated the binary content and streamed it to the response output stream?

4.2.f

Custom 404 error message if document not found

$
0
0

Hello,

I want to display a custom error message when file is not found using "View in browser" feature in Alfresco Share.

Example test file:
https://mydomain/share/proxy/alfresco/api/node/content/workspace/SpacesStore/70d263f4-f9e6-498d-93b2-549f64fbaa83/test1.txt

My document test1.txt doesn't exist so Alfresco return an standard error message with all traces. OK.
However, I don't want my users see this page.
I would like to replace this with a custom page or friendly message.

Following these subjects:
http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#your-first-web-script
https://forums.alfresco.com/forum/developer-discussions/web-scripts/friendly-error-pages-02192009-1431

I created a plain text file nammed 404.html.ftl in Data Dictionnary/Web Scripts folder, with custom content:

<html><body><p>My custom message.</p></body></html>

Refresh the webscript and put the test file URL, I still get the Alfresco standard error message (cf AlfrescoError404_fileNotFound.png)

Rename 404.html.ftl to 404.ftl, refresh the webscript, and I get the browser error message for 404 error, but not my custom message (cf IEError404_fileNotFound.png).

How can I display my custom message?

Thanks for your help.

4.2.e

Aegument handling web script

$
0
0

<p>${text!}</p>

what is the use of ! in this code?

Tushar Thakkar
Assistant System Engineer -Trainee
TATA Consultancy Services

Viewing all 105 articles
Browse latest View live