Alle Rechte, die Sie in Ihrem Projekt definieren, werden im Project Management > Business Objects main-java in der Klasse AuthorizationResources.java verwaltet. Diese Klasse wird automatisch generiert, sobald Sie das erste Mal eine UI-Komponente mit einem Benutzerrecht verknüpfen, z.B. einen XdevButton Button Save mit dem Recht CustomerSave.
Image RemovedImage Added
Code Block |
---|
language | java |
---|
theme | Confluence |
---|
|
package com.company.example.business.demoproj;
import java.util.MissingResourceException;
import com.xdevrapidclipse.framework.security.authorization.Resource;
import com.rapidclipse.xdevframework.security.authorization.ResourceEnum;
import com.xdevrapidclipse.framework.server.resources.Caption;
import com.rapidclipse.framework.server.resources.StringResourceUtils;
import com.rapidclipse.framework.server.security.authorization.ui.Authorization;
/**
* Central collection of all authorization resources used in the project.
*/
@Caption("{%description}")
public enum AuthorizationResources implements ResourceEnum<AuthorizationResources>
{
CUSTOMERSAVE("CustomerSave")
;
/**
* Helper method to export all resource names.
* <p>
* Right click and select 'Run As' - 'Java Application'
* </p>
*/
public static void main(String[] args)
{
for (AuthorizationResources value : AuthorizationResources.values())
{
System.out.println(value.name);
}
}
/////////////////////////////
// implementation details //
///////////////////////////
private final String name;
private Resource resource;
private String description;
private AuthorizationResources(final String name)
{
this.name = name;
}
@Override
public String resourceName()
{
return this.name;
}
@Override
public Resource resource()
{
if (this.resource == null)
{
this.resource = Authorization.resource(this.name);
}
return this.resource;
}
public String getDescription()
{
if(this.description == null)
{
try
{
this.description = StringResourceUtils.getResourceString(name(), this);
}
catch(final MissingResourceException e)
{
this.description = this.name;
}
}
return this.description;
}
} |
Rechte hinzufügen
Weitere Rechte können Sie jeweils bei der Verknüpfung einer UI-Komponente mit einem Recht per Assistent hinzufügen oder zentral in dieser Klasse, indem Sie einfach weitere Rechte anhängen.
Code Block |
---|
language | java |
---|
theme | Confluence |
---|
|
package com.company.example.businessdemoproj;
import java.util.MissingResourceException;
import com.xdevrapidclipse.framework.security.authorization.Resource;
import com.rapidclipse.xdevframework.security.authorization.ResourceEnum;
import com.rapidclipse.framework.server.resources.Caption;
import com.rapidclipse.framework.server.resources.StringResourceUtils;
import com.rapidclipse.framework.xdevserver.security.authorization.ui.Authorization;
/**
* Central collection of all authorization resources used in the project.
*/
@Caption("{%description}")
public enum AuthorizationResources implements ResourceEnum<AuthorizationResources>
{
CUSTOMERSAVE("CustomerSave"),
CUSTOMERNEW("CustomerNew"),
CUSTOMERUPDATE("CustomerUpdate"),
CUSTOMERDELET("CustomerDelete"),
PRODUCTSAVE("ProductSave"),
PRODUCTNEW("ProductNew"),
PRODUCTUPDATE("ProductUpdate"),
PRODUCTDELETE("ProductDelete")
; |
...