[opencms-dev] Re: Re: access rendered content which is not yet published
Sam Razialruh
Sam.Razialruh at abaxx.de
Fri Jan 23 10:10:02 CET 2004
hello again,
thanks for your tip.
now i tried using the jakarta.apache commons-http package to login
first.
but still the same :-(
String url =
"http://localhost:8280/opencms/opencms/system/workplace/action/explorerS
howResource.html?url=/abxopencms/opencms/example/example.html"
// i also tried this url:
// String url =
"http://localhost:8280/opencms/opencms/example/example.html"
GetMethod get = null;
HttpClient httpClient = new HttpClient();
httpClient.getState().setCredentials(null, null,
new UsernamePasswordCredentials(
"Admin",
"admin") );
get = new GetMethod(url);
get.setDoAuthentication(true);
httpClient.executeMethod(get);
InputStream stream = get.getResponseBodyAsStream();
ByteArrayOutputStream baout = new ByteArrayOutputStream();
int j = 0;
while (j != -1) {
byte[] readBytes = new byte[100000];
j = stream.read(readBytes);
if (j == -1) break;
byte[] writeBytes = new byte[j];
for (int k = 0; k < writeBytes.length; k++) {
writeBytes[k] = readBytes[k];
}
baout.write(writeBytes);
}
stream.close();
baout.flush();
baout.close();
ByteArrayOutputStream b = new ByteArrayOutputStream();
b.write(baout.toByteArray());
//this is not the "unpublished" content.....
System.out.println("new String(baout.toByteArray()) = " + new
String(baout.toByteArray()));
get.releaseConnection();
thank you all,
sam razialruh
> Date: Thu, 22 Jan 2004 11:20:49 -0700
> From: M Butcher <mbutcher at grcomputing.net>
> Subject: Re: [opencms-dev] access rendered content which is
> not yet published
>
> I think you'd have to log in, and make sure that that user has its
> default project set to offline.
>
> Sam Razialruh wrote:
> > hello,
> >
> > how can i access content within java-code, which is not yet
> published.
> > using
> > URL url = new URL("/example/example.html");
> > InputStream stream = url.openStream();
> > .....
> > .....
> > stream.close();
> > gives me only the published content of the url.
> > what i want is somehow receive the rendered content, which
> is not yet
> > published.
> >
> > i also tried, with the same effect:
> > URL url = new
> >
> URL(http://localhost:8280/opencms/opencms/system/workplace/action/expl
> > or
> > erShowResource.html?url=/example/example.html");
> > .....
> >
> > can someone please help me out?
More information about the opencms-dev
mailing list