How to make an Entity updatable but not insertable or deletable in OpenXava? - openxava

What if some entities should'n be deletable or insertable? Is there an easy way to get rid of the "new" button and trash can icon?

If you're using XavaPro just remove the access to the new and delete actions for the role. Otherwise, you should create a controller with just the save action and define a module using it.
That is, in controllers.xml add:
<controller name="OnlySave">
<action name="save" mode="detail"
by-default="if-possible"
class="org.openxava.actions.SaveAction"
image="save.gif"
icon="content-save"
keystroke="Control S"/>
</controller>
And in application.xml define a module for your entity in this way:
<module name="Customer">
<model name="Customer"/>
<controller name="OnlySave"/>
<controller name="Print"/>
</module>

Related

Difference between <itemtype generate="false"> and <model generate="false"/> in Hybris Models

I wanted to understand the difference between and in Hybris for Model creation. How do they function internally?
<model generate="false"/> can be used in some contexts:
1) In <itemtype> to exclude the type from being created (including all subtypes) and can be used like in this example:
<itemtype ....>
<model generate="false"/>
</itemtype>
2) In <attribute> context to exclude the attribute from being created. The result is that neither the private field nor getter and setter methods are generated!
<attribute ...>
<model generate="false"/>
</attribute>
I didn't found any utility yet for this case.
The <itemtype generate="false/true"/> is used to specify to generate the Java class files or not (for getters/setters).
You can read here more information about <model/> tag (create custom getters/setters/constructors for an itemtype)

Wrong alias pattern when importing taxonomy terms

I'm trying to leverage Import/Export module to import taxonomies and taxonomy terms like so
<Orchard>
<Data>
<Taxonomy Id="/Identifier=Product-Categories" Status="Published">
<AutoroutePart Alias="eshop/categories" UseCustomPattern="false" />
<IdentityPart Identifier="Product-Categories" />
<TitlePart Title="Product Categories" />
<TaxonomyPart TermTypeName="ProductCategoriesTerm" />
</Taxonomy>
<ProductCategoriesTerm Id="/Identifier=Category-1" Status="Published">
<AutoroutePart UseCustomPattern="false" />
<IdentityPart Identifier="Category-1" />
<TitlePart Title="Test category" />
<TermPart Count="0" Selectable="true" Weight="1" TaxonomyId="/Identifier=Product-Categories" Path="" />
</ProductCategoriesTerm>
</Data>
</Orchard>
ProductCategoriesTerm when created through dashboard has default pattern
{Content.Container.Path}/{Content.Slug} ### my-taxonomy/my-term/sub-term
but importing terms makes them to use just {Content.Slug} ... How do I instruct AutoroutePart to use the default pattern? Tried UseCustomPattern="false" or exclude AutoroutePart with no effect it's just test-category instead of eshop/categories/test-category and won't regenerate even if if I set AutouroutePart to automatically regenerate when editing content and disable custom patterns and it won't revert to default pattern even if I try to publish it through dashboard.
Also it's mandatory to include "Count" for the TermPart when importing, does it affect anything? Sounds like something that should be dynamic and relevant only with export.
When importing taxonomy terms (and I guess any other part that has a container) it's necessary to specify Container for the common part. Without it Container for the part is null and therefore can't resolve {Content.Container.Path} in the alias pattern.
<CommonPart Container="/Identifier=Product-Categories" />
Or if it's nested term then Container is the parent term.

How to create a secure login system for JSP?

I was given a JSP page where anyone can just view the page source and find the Username and password. My task is to make it somewhat secure. After some reading, I figured I would want to implement an SHA-256 encryption system, but I am not too sure how to do this.
How should I store the hashed passwords? I have barely any experience with JSP / security, so I don't fully understand the steps. After a user enters his password, and it gets encrypted with SHA 256, does this string get compared to a string in a text file? What's the best way for this?
What is the difference between having the entire procedure done in one JSP file versus multiple. I notice how sometimes the login and encryption occurs in the same file while other times, the form uses other JSP files.
go for spring web mvc+spring security plug in it provides all you need with just xml and data base
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/admin*" access="hasAnyRole('ROLE_Admin')" />
<form-login login-page="/login" default-target-url="/welcome"
authentication-failure-url="/loginfailed" />
<logout logout-success-url="/login" />
</http>
<authentication-manager>
<authentication-provider>
<password-encoder hash="sha256"/>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="
select username,password, enabled
from users where username=?"
authorities-by-username-query="
select u.username, u.authority from users u
where u.username =? "
/>
</authentication-provider>
</authentication-manager>
</beans:beans>

How to prevent self-referencing foreign key values in XSD schema?

My XML (simplified) is like this:
<Actions>
<Action Id="1">
</Action>
<Action Id="2">
<DoSomething>
<ActionRef ActionId="1" /> <!-- valid -->
</DoSomething>
</Action>
</Actions>
The ActionId attribute value references the Id attribute value of the Action element. I've already set up a foreign key constraint in the XSD, and it works correctly.
I want to prevent self-referencing values in the foreign field, like this:
<Actions>
<Action Id="1">
</Action>
<Action Id="2">
<DoSomething>
<ActionRef ActionId="2" /> <!-- invalid -->
</DoSomething>
</Action>
</Actions>
Of course, this can easily be done within the application that processes the XML, and I'll fall back on that if what I'm asking for isn't possible, but I'd much rather have this done automatically by the validation process.
I tried adding [not(#ActionId = ../#Id)] to the foreign key selector XPath query, but that isn't valid in that context (nor am I sure it's correct either). Other than that, I have no idea what else to try, and it doesn't look like many people on the internets even set up foreign key relationships in their XSDs, let alone prevent this kind of situation (I found nothing on this exact topic).
It cannot be done - the selector syntax for XSD constraints is very limited. Other alternatives may include Schematron, which should be reasonable to integrate assuming your runtime has access to an XSLT processor. The effort could pay off is you decide to add more validation rules separate from the code of the application that processes the XML.

Can't create params for custom component

I'm currently working on a custom joomla component but I fail to get the component wide parameters to work.
The joomla docs say that if you add
to your 'myComponent.xml' file, the parameter should appear in the _components table. I do see my component but there are no params there.
Is there anything I should know? Or anything I might do wrong?
here is test.xml { myComponent.xml }:
<?xml version="1.0" encoding="UTF-8"?>
<install type="component" version="1.5.0">
<name>test</name>
<creationDate>2010-08-05</creationDate>
<author>test</author>
<version>1.0.0</version>
<description>test</description>
<administration>
<menu>Ctest</menu>
<files folder="admin">
<filename>controller.php</filename>
<filename>test.php</filename>
<filename>index.html</filename>
<filename>models/test.php</filename>
<filename>models/index.html</filename>
<filename>views/index.html</filename>
<filename>views/test/index.html</filename>
<filename>views/test/view.html.php</filename>
<filename>views/test/tmpl/default.php</filename>
<filename>views/test/tmpl/index.html</filename>
</files>
</administration>
<params>
<param name="test" type="text" default="" label="test" description="test" />
</params>
</install>
Make sure you're configuring the params correctly in both places config is needed.
In COMPONENTNAME.xml, you need the block you've got above (although I think only 'name' and 'default' are used here).
Also, in admin/config.xml, you'll need something like:
<root>
<params>
<param type="text" name="test" size="30" label="test" description="test" />
</params>
</root>
You'll then need to make sure there's a way to get to these config options, with this in your 'toolbar.COMPONENTNAME.html.php':
JToolBarHelper::preferences('com_magentocatalogue');
Then, a 'config' button should appear in the toolbar for your component. Only once you save some changes will these parameters appear in the #__components.params field.

Resources