Re: How to add a link to a file stored in directory?

2013-06-04 Thread mailingl...@j-b-s.de
Hi Petr!

You are really refering to a file in your src directory? When you use maven to 
build it the file is copied to target/ and you access it simply by "return.txt" 
using the classloader because target/resources is stripped when building the 
jar/war.

Set a break point and check if you really got an inputstream. You can also try 
to get the URL first which is null in case nothing found.

Jens

Sent from my iPhone

On 05.06.2013, at 00:01, Petr Janata  wrote:

> Hi,
> 
> thanks for links with ideas. I am new in Tapestry I use Example
> App
> from
> Jumpstart tutorial . I added File
> Upload
> to
> Example App and HSQL table for uploaded file names. In Example App is
> used Protecting
> Pages
> and
> I can not download uploaded file by simple href even if I am logged in as a
> admin user.
> 
> How to allow to download file from upload-path?
> 
> I use simple link in  tml file
> 
> download
> 
> and I also added  onReturnStreamResponse into java file from jumpstart
> tutorial from this link.
> 
> StreamResponse onReturnStreamResponse() {
>return new StreamResponse() {
>InputStream inputStream;
> 
>@Override
>public void prepareResponse(Response response) {
>ClassLoader classLoader =
> Thread.currentThread().getContextClassLoader();
>inputStream =
> classLoader.getResourceAsStream("regoznapp/enterprise/src/main/resources/return.txt");
> 
>// Set content length to prevent chunking - see
>//
> http://tapestry-users.832.n2.nabble.com/Disable-Transfer-Encoding-chunked-from-StreamResponse-td5269662.html#a5269662
> 
>try {
>response.setHeader("Content-Length", "" +
> inputStream.available());
>}
>catch (IOException e) {
>// Ignore the exception in this simple example.
>}
>}
> 
>@Override
>public String getContentType() {
>return "text/plain";
>}
> 
>@Override
>public InputStream getStream() throws IOException {
>return inputStream;
>}
>};
> }
> 
> Petr

-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: How to add a link to a file stored in directory?

2013-06-04 Thread Geoff Callender
1. What happens? Is an exception thrown?

2. If you upload to the file system, like the jumpstart example does; then you 
should download from the file system - but your example, below, is downloading 
from a path relative to the classpath of the web app. Try this instead:

inputStream = new FileInputStream(myFilePath);

Geoff

On 05/06/2013, at 8:01 AM, Petr Janata wrote:

> Hi,
> 
> thanks for links with ideas. I am new in Tapestry I use Example
> App
> from
> Jumpstart tutorial . I added File
> Upload
> to
> Example App and HSQL table for uploaded file names. In Example App is
> used Protecting
> Pages
> and
> I can not download uploaded file by simple href even if I am logged in as a
> admin user.
> 
> How to allow to download file from upload-path?
> 
> I use simple link in  tml file
> 
> download
> 
> and I also added  onReturnStreamResponse into java file from jumpstart
> tutorial from this link.
> 
> StreamResponse onReturnStreamResponse() {
>return new StreamResponse() {
>InputStream inputStream;
> 
>@Override
>public void prepareResponse(Response response) {
>ClassLoader classLoader =
> Thread.currentThread().getContextClassLoader();
>inputStream =
> classLoader.getResourceAsStream("regoznapp/enterprise/src/main/resources/return.txt");
> 
>// Set content length to prevent chunking - see
>//
> http://tapestry-users.832.n2.nabble.com/Disable-Transfer-Encoding-chunked-from-StreamResponse-td5269662.html#a5269662
> 
>try {
>response.setHeader("Content-Length", "" +
> inputStream.available());
>}
>catch (IOException e) {
>// Ignore the exception in this simple example.
>}
>}
> 
>@Override
>public String getContentType() {
>return "text/plain";
>}
> 
>@Override
>public InputStream getStream() throws IOException {
>return inputStream;
>}
>};
> }
> 
> Petr



Re: FormFragment stops working after refreshing containing zone

2013-06-04 Thread Ilya Obshadko
On Tue, Jun 4, 2013 at 8:50 PM, Lance Java wrote:

> Short answer:
> Try …
>
>
>
> Long answer:
> The form's zone parameter refers to the zone's clientId (not to be confused
> with the serverside id). Tapestry will auto generate a unique clientId for
> your zone unless you provide an explicit clientId.
>

I know about usage of clientId. I don't completely understand - is it
connected somehow with invalid FormFragment state after zone update?


-- 
Ilya Obshadko


Re: FormFragment stops working after refreshing containing zone

2013-06-04 Thread Ilya Obshadko
I'm using multiple zone update. Hence, it's AjaxResponseRenderer and void
onSuccessFromForm ().


On Tue, Jun 4, 2013 at 8:55 PM, Lance Java wrote:

> Also, what are you returning from your submit event? zone or
> zone.getBody()?
>
> You should return the latter
>



-- 
Ilya Obshadko


How to add a link to a file stored in directory?

2013-06-04 Thread Petr Janata
Hi,

thanks for links with ideas. I am new in Tapestry I use Example
App
from
Jumpstart tutorial . I added File
Upload
to
Example App and HSQL table for uploaded file names. In Example App is
used Protecting
Pages
and
I can not download uploaded file by simple href even if I am logged in as a
admin user.

How to allow to download file from upload-path?

I use simple link in  tml file

download

and I also added  onReturnStreamResponse into java file from jumpstart
tutorial from this link.

StreamResponse onReturnStreamResponse() {
return new StreamResponse() {
InputStream inputStream;

@Override
public void prepareResponse(Response response) {
ClassLoader classLoader =
Thread.currentThread().getContextClassLoader();
inputStream =
classLoader.getResourceAsStream("regoznapp/enterprise/src/main/resources/return.txt");

// Set content length to prevent chunking - see
//
http://tapestry-users.832.n2.nabble.com/Disable-Transfer-Encoding-chunked-from-StreamResponse-td5269662.html#a5269662

try {
response.setHeader("Content-Length", "" +
inputStream.available());
}
catch (IOException e) {
// Ignore the exception in this simple example.
}
}

@Override
public String getContentType() {
return "text/plain";
}

@Override
public InputStream getStream() throws IOException {
return inputStream;
}
};
}

Petr


Tapestry 5.4-alpha-8

2013-06-04 Thread Howard Lewis Ship
Fixed another annoying bug and cleaned up a couple of more things.

Maven repository:
https://repository.apache.org/content/repositories/orgapachetapestry-071/

-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Contribute multiple collections in the same service?

2013-06-04 Thread Howard Lewis Ship
There's a huge complexity cost for allowing a single service to expose
multiple configurations, and its rare to need. Often, a solution that
breaks the single service into two (or more) services, even if just to
support the constraint of a single configuration, leads to better, more
testable code anyway.


On Tue, Jun 4, 2013 at 6:53 AM, Lance Java wrote:

> Yes, this is a limitation of tapestry contributions. This can be worked
> around.
>
> Create a MapConfigProvider service which has a getter for the MapConfig
> collection. Contribute MapConfig objects to the MapConfigProvider.
>
> Then pass the MapConfigProvider and the second collection to your
> HazelcastConfigServiceImpl.
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com


Re: Tapestry Security / page instance / invocation question

2013-06-04 Thread Richard Frovarp

On 06/04/2013 11:03 AM, Dmitry Gusev wrote:

Just a note that you always can write your own component like this if you
want:





That's probably the better long term solution for my environment.


On Tue, Jun 4, 2013 at 7:50 PM, Richard Frovarp  wrote:


That would work. The trick is that I need to compute the permissions
dynamically. I'll have to add in more code to handle those types of
wildcard permissions. I was hoping for something much more similar to what
I can use with the @RequiresPermissions check. But since I don't have an
invocation, that looks like what I'll have to do.



I'm not sure I understand you, how would this differ from the case with
MethodInvoication?
Isn't the same AuthorizingRealm will check permissions for you?
Just check if your permission has targets set and if it has - you can just
peek instance from them.
If not - try to get if from MethodInvoication.

Anyway, if you need that invocation - you can create one - just call some
method from your new component newPermission2 and intercept that call with
@RequiresPermissions. But you can't declare dynamic permission in the
annotation, you do understand this, right?




By using the MethodInvocation (and perhaps actually getting the 
instance), I get the object to inspect directly, instead of having to 
get Cayenne to retrieve it for me via the object id.


What I've done is to create a realm that uses reflection / introspection 
to find methods annotated with a special annotation. The string in that 
annotation matches exactly with the permission being checked. When 
permission checks come in, they are dispatched to the method marked as 
being responsible for that permission.


So this:
@RequiresPermissions(ILACAuth.SERVICE_MANAGE_VIEW_INSTANCE)
public void onActivate(Service service) {

ends up getting processed by this:
@InstanceAccessMethod(ILACAuth.SERVICE_MANAGE_VIEW_INSTANCE)
public boolean isPermittedViewService() {
  MethodInvocation methodInvocation = getInvocation();

  if (methodInvocation == null) {
return false;
  }

  Object instance = methodInvocation.getInstance();
...
}

Where the permission is: servicemanager:view:instance.

This idea works everywhere, except for template rendering. I do support 
passing in the permission being checked when dispatching the call. I 
just need to get around the exact string matching I'm doing. This will 
probably require a locally reserved word in the permission to make it work.


So to handle the template scenario, I probably need to do something 
like: servicemanager:view:instance:key:265 and then know to chop :key on 
to dispatch to the correct check, and pass the permission in so it can 
have Cayenne retrieve the correct record if necessary. My method would 
have to change as well. It's not insurmountable, it just requires more 
work to set everything up.


The key thing is I now understand that I can't get what I need via 
MethodInvocation when rendering, so I don't bang my head against that wall.


Thanks,
Richard


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Tapestry links not https

2013-06-04 Thread Dmitry Gusev
Here's how I solve this problem with Tomcat and OpenShift:

I declare these Symbol values:

tapestry.hostname=.rhcloud.com
tapestry.hostport=80
tapestry.hostport-secure=443
tapestry.secure-enabled=true

I put @Secure to my pages.

And I declare RemoteIpValve in my application context like this:











This tomcat instance is running on port 8080 and 8433 in the cloud.

On Tue, Jun 4, 2013 at 7:57 PM, Richard Frovarp  wrote:

> On 05/31/2013 02:45 PM, John wrote:
>
>> My tapestry app doesn't work with SSL set up, the links have port 443
>> added but start http://.
>>
>> There must be some configuration missing?
>>
>> John
>>
>>
> You may also want to look at: MetaDatConstants.SECURE_PAGE. I know even
> with AJP proxying to Tomcat, we've ran into troubles. We just set that to
> true when in production, and that fixes our links.
>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Tapestry Security / page instance / invocation question

2013-06-04 Thread Dmitry Gusev
Just a note that you always can write your own component like this if you
want:



On Tue, Jun 4, 2013 at 7:50 PM, Richard Frovarp  wrote:

> That would work. The trick is that I need to compute the permissions
> dynamically. I'll have to add in more code to handle those types of
> wildcard permissions. I was hoping for something much more similar to what
> I can use with the @RequiresPermissions check. But since I don't have an
> invocation, that looks like what I'll have to do.


I'm not sure I understand you, how would this differ from the case with
MethodInvoication?
Isn't the same AuthorizingRealm will check permissions for you?
Just check if your permission has targets set and if it has - you can just
peek instance from them.
If not - try to get if from MethodInvoication.

Anyway, if you need that invocation - you can create one - just call some
method from your new component newPermission2 and intercept that call with
@RequiresPermissions. But you can't declare dynamic permission in the
annotation, you do understand this, right?


>
> On 05/30/2013 11:34 AM, Dmitry Gusev wrote:
>
>> You don't have invocation here, because you're rendering.
>> And you should know what you're rendering, so you should be able to do
>> this:
>>
>> 
>>
>> and in Java:
>>
>> public String getMyPermission()
>> {
>>  return "some:permission:" + instance.getId();
>> }
>>
>> will this work?
>>
>> On Thu, May 30, 2013 at 8:29 PM, Richard Frovarp > >wrote:
>>
>>  I'm using the Tynamo tapestry-security library to great success. I've
>>> been
>>> progressing through the instance level pieces and things are going well.
>>>
>>> I've ran into a bit of a problem however. I can do the instance level
>>> checks with @RequiresPermissions on functions just fine. That is
>>> populating
>>> the Environment service with the MethodInvocation. All is well. I can
>>> either get the method, or the instance, and proceed to do my security
>>> checks.
>>>
>>> The problem I'm running into is with the soft checks, in particular
>>>  where I want to
>>> decide if a link should be shown or not.
>>>
>>> That will trigger the checks, however, that doesn't populate the
>>> Environment with the MethodInvocation. So I have no way of telling what
>>> is
>>> being checked.
>>>
>>> Is there a way to get the current invocation without going through the
>>> environment service? Or should I come up with my own annotation, turn the
>>> security annotation into if checks, and use the advise pieces to put the
>>> invocation into the environment?
>>>
>>> This section of Tapestry is still confusing to me, so I hope that my
>>> question makes sense.
>>>
>>> Thanks,
>>> Richard
>>>
>>> --**
>>> --**-
>>> To unsubscribe, e-mail: 
>>> users-unsubscribe@tapestry.**a**pache.org
>>> 
>>> >
>>>
>>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>>
>>>
>>>
>>
>>
>
> --**--**-
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Dmitry Gusev

AnjLab Team
http://anjlab.com


Re: Tapestry links not https

2013-06-04 Thread Richard Frovarp

On 05/31/2013 02:45 PM, John wrote:

My tapestry app doesn't work with SSL set up, the links have port 443 added but 
start http://.

There must be some configuration missing?

John



You may also want to look at: MetaDatConstants.SECURE_PAGE. I know even 
with AJP proxying to Tomcat, we've ran into troubles. We just set that 
to true when in production, and that fixes our links.


-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Tapestry Security / page instance / invocation question

2013-06-04 Thread Richard Frovarp
That would work. The trick is that I need to compute the permissions 
dynamically. I'll have to add in more code to handle those types of 
wildcard permissions. I was hoping for something much more similar to 
what I can use with the @RequiresPermissions check. But since I don't 
have an invocation, that looks like what I'll have to do.


On 05/30/2013 11:34 AM, Dmitry Gusev wrote:

You don't have invocation here, because you're rendering.
And you should know what you're rendering, so you should be able to do this:



and in Java:

public String getMyPermission()
{
 return "some:permission:" + instance.getId();
}

will this work?

On Thu, May 30, 2013 at 8:29 PM, Richard Frovarp wrote:


I'm using the Tynamo tapestry-security library to great success. I've been
progressing through the instance level pieces and things are going well.

I've ran into a bit of a problem however. I can do the instance level
checks with @RequiresPermissions on functions just fine. That is populating
the Environment service with the MethodInvocation. All is well. I can
either get the method, or the instance, and proceed to do my security
checks.

The problem I'm running into is with the soft checks, in particular
 where I want to
decide if a link should be shown or not.

That will trigger the checks, however, that doesn't populate the
Environment with the MethodInvocation. So I have no way of telling what is
being checked.

Is there a way to get the current invocation without going through the
environment service? Or should I come up with my own annotation, turn the
security annotation into if checks, and use the advise pieces to put the
invocation into the environment?

This section of Tapestry is still confusing to me, so I hope that my
question makes sense.

Thanks,
Richard

--**--**-
To unsubscribe, e-mail: 
users-unsubscribe@tapestry.**apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org








-
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Contribute multiple collections in the same service?

2013-06-04 Thread Lance Java
Yes, this is a limitation of tapestry contributions. This can be worked
around.

Create a MapConfigProvider service which has a getter for the MapConfig
collection. Contribute MapConfig objects to the MapConfigProvider.

Then pass the MapConfigProvider and the second collection to your
HazelcastConfigServiceImpl.


Contribute multiple collections in the same service?

2013-06-04 Thread Ferran Maylinch
Hello,

I would like to contribute 2 collections to a service, but I am afraid
Tapestry only supports one collection to be contributed. Am I right?

My service constructor is like this:

public HazelcastConfigServiceImpl(
 final Collection mapConfigs,
final Collection hzConfigurers) { ... }

And I try to contribute the hzConfigurers this way:

@Contribute(HazelcastConfigService.class)
 public static void
contributeExecutorConfig(Configuration hzConfigurers)
 {
hzConfigurers.add(new HazelcastConfigurer()
 {
@Override
 public void configure(Config config)
{
 config.addExecutorConfig(
new ExecutorConfig(RankingsConstants.RANKINGS_EXECUTOR_SERVICE_NAME)
 .setCorePoolSize(5)
.setMaxPoolSize(5)
 );
}
 });
}

But I get this exception:

Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Could not
find a coercion from type
com.mobivery.malcom.categories.rankings.workers.services.MalcomRankingsWorkersModule$1
to type com.hazelcast.config.MapConfig.

It seems it is trying to insert my HazelcastConfigurer into
the mapConfigs when it should go to the hzConfigurers.

Thank you

-- Ferran


Re: FormFragment stops working after refreshing containing zone

2013-06-04 Thread Lance Java
Also, what are you returning from your submit event? zone or
zone.getBody()?

You should return the latter


Re: FormFragment stops working after refreshing containing zone

2013-06-04 Thread Lance Java
Short answer:
Try …



Long answer:
The form's zone parameter refers to the zone's clientId (not to be confused
with the serverside id). Tapestry will auto generate a unique clientId for
your zone unless you provide an explicit clientId.


Re: Tapetsry IoC service constructor

2013-06-04 Thread Kalle Korhonen
I bet this is mentioned somewhere, but you have to use field injection with
multiple persistence contexts - it's a limitation of tapestry-jpa.

Kalle

On Tue, Jun 4, 2013 at 1:44 AM, John  wrote:

> The following is invalid, how to do it properly please? The docs assume
> field level injection and don't discus contructor based dependency.
>
> John
>
> public AuditingDAO(@PersistenceContext(unitName = "DBUnit") EntityManager
> entityManager) {
>
> ...
>


Tapetsry IoC service constructor

2013-06-04 Thread John
The following is invalid, how to do it properly please? The docs assume field 
level injection and don't discus contructor based dependency.

John

public AuditingDAO(@PersistenceContext(unitName = "DBUnit") EntityManager 
entityManager) {

...