Changeset 690
- Timestamp:
- 02/08/12 12:39:44 (3 months ago)
- Location:
- Core/trunk
- Files:
-
- 6 edited
-
documentation/corinis.xml (modified) (2 diffs)
-
pom.xml (modified) (1 diff)
-
src/main/java/corinis/modules/AuthorityManager.java (modified) (7 diffs)
-
src/main/java/corinis/modules/MailCenter.java (modified) (1 diff)
-
src/main/java/corinis/modules/abstracts/DynamicField.java (modified) (3 diffs)
-
src/main/java/corinis/modules/util/Eventer.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
Core/trunk/documentation/corinis.xml
r681 r690 311 311 <RIGHT>USERMANAGER_SYNC</RIGHT> 312 312 <FILE>auto</FILE> 313 </USERSYNC> 313 </USERSYNC> 314 314 </USERMANAGER> 315 315 316 <!-- Named Guests317 Allow guest users to login, with a username without a password.318 If verifyusers is set to TRUE, users must verify their account before319 being able to log in.320 The file specified in verifymail is the mail body for verification - $name will be321 replaced by the username, $verify by the verify string. The mail will be sent322 as html-mail.323 Make sure the email has an url similar to:324 http://www.corinis.com/verify.jsp?Login_username=&username;&Login_verify=&verify;325 where username and verify will be replaced by the generated values.326 If you want to use ntlm auth enable the option and make sure that you call the Login.ntlmauth() function before327 anything else.328 If you want to authenticate against a domain controller enable it and set domain/domaincontroller329 The defaultgroup(s) are added to the user if a new one has to be created.330 If you want to enable basic authenticated set BASICAUTH to true - basic authenticaten331 disables the use of guest users automaticalle since every not authenticated user gets a user/password332 windoe (or not if using a domain authenticaton)333 -->334 <LOGIN>335 <GUESTUSERS>true</GUESTUSERS>336 <ALLOWEMAILLOGIN>false</ALLOWEMAILLOGIN>337 338 <SALT>false</SALT>339 <BASICAUTH>false</BASICAUTH>340 341 <USENTLM>false</USENTLM>342 343 <USENTDOMAINAUTH>false</USENTDOMAINAUTH>344 <DOMAIN>CORINIS</DOMAIN>345 <DOMAINCONTROLLER>192.168.1.1</DOMAINCONTROLLER>346 <DEFAULTGROUP>ADMIN</DEFAULTGROUP>347 348 <!-- if passwordreplybody is not set -> no way to retrieve the password -->349 <PASSWORDRETRIEVAL>true</PASSWORDRETRIEVAL>350 <PASSWORDREPLYNAME>noreply</PASSWORDREPLYNAME>351 <PASSWORDREPLYEMAIL>noreply@localhost</PASSWORDREPLYEMAIL>352 <PASSWORDREPLYSUBJECT>Your new password at localhost</PASSWORDREPLYSUBJECT>353 <!-- Use $password; in the body which will be replaced by the user's password -->354 355 <PASSWORDREPLYBODY>auto</PASSWORDREPLYBODY>356 </LOGIN>357 <!--358 Mailcenter Module359 360 The attachment dir does not have to be web accessable!361 362 If you specify the MAILER entry, the system will use the specified program363 to send mails (senmail style), if this entry does not exist it will use364 the smtp server specified.365 366 the maillog logs the messages sent through the mailcenter in xml format:367 <MESSAGE>368 <SUBJECT>369 <SENDER>370 <RECEPIENT>371 <CC>372 <BODY>373 </MESSAGE>374 -->316 <!-- Named Guests 317 Allow guest users to login, with a username without a password. 318 If verifyusers is set to TRUE, users must verify their account before 319 being able to log in. 320 The file specified in verifymail is the mail body for verification - $name will be 321 replaced by the username, $verify by the verify string. The mail will be sent 322 as html-mail. 323 Make sure the email has an url similar to: 324 http://www.corinis.com/verify.jsp?Login_username=&username;&Login_verify=&verify; 325 where username and verify will be replaced by the generated values. 326 If you want to use ntlm auth enable the option and make sure that you call the Login.ntlmauth() function before 327 anything else. 328 If you want to authenticate against a domain controller enable it and set domain/domaincontroller 329 The defaultgroup(s) are added to the user if a new one has to be created. 330 If you want to enable basic authenticated set BASICAUTH to true - basic authenticaten 331 disables the use of guest users automaticalle since every not authenticated user gets a user/password 332 windoe (or not if using a domain authenticaton) 333 --> 334 <LOGIN> 335 <GUESTUSERS>true</GUESTUSERS> 336 <ALLOWEMAILLOGIN>false</ALLOWEMAILLOGIN> 337 338 <SALT>false</SALT> 339 <BASICAUTH>false</BASICAUTH> 340 341 <USENTLM>false</USENTLM> 342 343 <USENTDOMAINAUTH>false</USENTDOMAINAUTH> 344 <DOMAIN>CORINIS</DOMAIN> 345 <DOMAINCONTROLLER>192.168.1.1</DOMAINCONTROLLER> 346 <DEFAULTGROUP>ADMIN</DEFAULTGROUP> 347 348 <!-- if passwordreplybody is not set -> no way to retrieve the password --> 349 <PASSWORDRETRIEVAL>true</PASSWORDRETRIEVAL> 350 <PASSWORDREPLYNAME>noreply</PASSWORDREPLYNAME> 351 <PASSWORDREPLYEMAIL>noreply@localhost</PASSWORDREPLYEMAIL> 352 <PASSWORDREPLYSUBJECT>Your new password at localhost</PASSWORDREPLYSUBJECT> 353 <!-- Use $password; in the body which will be replaced by the user's password --> 354 355 <PASSWORDREPLYBODY>auto</PASSWORDREPLYBODY> 356 </LOGIN> 357 <!-- 358 Mailcenter Module 359 360 The attachment dir does not have to be web accessable! 361 362 If you specify the MAILER entry, the system will use the specified program 363 to send mails (senmail style), if this entry does not exist it will use 364 the smtp server specified. 365 366 the maillog logs the messages sent through the mailcenter in xml format: 367 <MESSAGE> 368 <SUBJECT> 369 <SENDER> 370 <RECEPIENT> 371 <CC> 372 <BODY> 373 </MESSAGE> 374 --> 375 375 <MAILCENTER> 376 376 <!-- <MAILER>/usr/lib/sendmail -i -t</MAILER> --> … … 382 382 </MAILCENTER> 383 383 384 <!--385 Cms Module386 387 The upload dir has to be web accessable!388 The uploadwebdir is the web path used when showing the documents!389 The uploadfiledir is for download files and should therefore be at a not390 web accessible location391 The staticpath specifies the path where the static files are located (normally392 the webroot). It is used for the admin filemanager and when static files from393 the cms are created.394 DATAFIELD specifies the content field were uploaded/parseable data is stored395 (f.e. from a pdf, word or excel file)396 RIGHTOVERRIDE: Allows to usage of the overriding-right request parameter (Document_right=)397 SKIPLIFEVIEW: skip all right checking in life system398 LINKCHECK: the time until the next linkcheck is being done (default ms, s - seconds, m - minutes, h - hours, d - days)399 SYSTEM: Here you can set what kind of management system you want. Possible values are (you can either use then umber, or the name):400 - default (3): use a quality management and life system (3-step system)401 - noqm (2): skip the qm, documents go streight from edit to life (2-step system)402 - onlylife (1): there is neither a qm, nor a life system. When pressing save it's on the page403 STATIC/PATH: Where static rendered information (xml/xhtml for cms) will be stored404 STATIC/RENDERGROUPS: the name of groups for which static renderd pages are served (if a user is more than one group, the highed priority will be used)405 FILEMANAGERCACHE: a directory where filemanger xml caches are stored (xml file)406 -->407 <CMS>408 <TEMPLATEPATH>auto</TEMPLATEPATH>409 <STATIC enable="true">410 <RENDERGROUPS>411 <GROUP priority="1">GUEST</GROUP>412 </RENDERGROUPS>413 <PATH>auto</PATH>414 </STATIC>415 416 <UPLOADDIR>auto</UPLOADDIR>417 <UPLOADWEBDIR>auto</UPLOADWEBDIR>418 <CACHING>false</CACHING>419 <SKIPLIFEVIEW>false</SKIPLIFEVIEW>420 <DATAFIELD>data</DATAFIELD>421 <RIGHTOVERRIDE>false</RIGHTOVERRIDE>422 <LINKCHECK>1h</LINKCHECK>423 <!--424 The Linkstyle can be any combination of path425 with $id replaced by the id and $path replaced426 by the absolute path to the document.427 Binary files will be automatically converted to their428 path429 If you want to use the real index.jsp for preview add430 &preview=true - this wil cause the cms taglib to use431 the edit system (if rights suffice)432 433 For multilanguage/tree stuff use $top[ID:"path"|ID2:"path2"|"defaultpath"]434 ie: $top[0:"en"|121423:"de"|"fr"]435 436 if you created the index.jsp with the corinis taglib you can use &preview=true437 to enable preview mode438 -->439 <LINKSTYLE>440 <PREVIEW>/corinis/modules/Cms/preview.jsp?Document_id=$id</PREVIEW>441 <LIFE>/index.jsp?Document_id=$id</LIFE>442 </LINKSTYLE>443 444 <!--445 define the target for files:446 INTERNAL: all internally linked documents447 EXTERNAL: all external urls448 FILES: all files (internal)449 -->450 <URLTARGET>451 <INTERNAL/>452 <EXTERNAL>_ext</EXTERNAL>453 <FILES>_blank</FILES>454 </URLTARGET>455 456 <!--Enable the QM System [default|fullqm] -->457 <SYSTEM>default</SYSTEM>458 459 </CMS>460 461 <!--462 Document Manager Module463 464 The uploaddir points to where the files will be stored.465 -->466 <DOCUMENTMANAGER>467 <UPLOADDIR>auto</UPLOADDIR>468 </DOCUMENTMANAGER>469 470 <!--471 Forum Module472 SUBSCRIBEEMAIL: the email address in the sent mail473 SUBSCRIBEHEADER: the header of the message - you can use $name; $id; $title;474 SUBSCRIBEBODY: path to a text file to be used as body, use $name; $id; $message; $title; in there475 if BODY is set to auto the file WEB-INF/forumsubscribe.txt will be loaded476 -->477 <FORUM>478 <SUBSCRIBEEMAIL>noreply@corinis.com</SUBSCRIBEEMAIL>479 <SUBSCRIBENAME>noreply</SUBSCRIBENAME>480 <SUBSCRIBESUBJECT>[Corinis Forum] New Forum Message: $title;</SUBSCRIBESUBJECT>481 <SUBSCRIBEBODY>auto</SUBSCRIBEBODY>482 </FORUM>483 484 <!-- Webalbum Module -->485 <PHOTOLIBRARY>486 <IMAGEFOLDER>auto</IMAGEFOLDER>487 <IMAGEWEBURL>auto</IMAGEWEBURL>488 </PHOTOLIBRARY>489 </MODULES>384 <!-- 385 Cms Module 386 387 The upload dir has to be web accessable! 388 The uploadwebdir is the web path used when showing the documents! 389 The uploadfiledir is for download files and should therefore be at a not 390 web accessible location 391 The staticpath specifies the path where the static files are located (normally 392 the webroot). It is used for the admin filemanager and when static files from 393 the cms are created. 394 DATAFIELD specifies the content field were uploaded/parseable data is stored 395 (f.e. from a pdf, word or excel file) 396 RIGHTOVERRIDE: Allows to usage of the overriding-right request parameter (Document_right=) 397 SKIPLIFEVIEW: skip all right checking in life system 398 LINKCHECK: the time until the next linkcheck is being done (default ms, s - seconds, m - minutes, h - hours, d - days) 399 SYSTEM: Here you can set what kind of management system you want. Possible values are (you can either use then umber, or the name): 400 - default (3): use a quality management and life system (3-step system) 401 - noqm (2): skip the qm, documents go streight from edit to life (2-step system) 402 - onlylife (1): there is neither a qm, nor a life system. When pressing save it's on the page 403 STATIC/PATH: Where static rendered information (xml/xhtml for cms) will be stored 404 STATIC/RENDERGROUPS: the name of groups for which static renderd pages are served (if a user is more than one group, the highed priority will be used) 405 FILEMANAGERCACHE: a directory where filemanger xml caches are stored (xml file) 406 --> 407 <CMS> 408 <TEMPLATEPATH>auto</TEMPLATEPATH> 409 <STATIC enable="true"> 410 <RENDERGROUPS> 411 <GROUP priority="1">GUEST</GROUP> 412 </RENDERGROUPS> 413 <PATH>auto</PATH> 414 </STATIC> 415 416 <UPLOADDIR>auto</UPLOADDIR> 417 <UPLOADWEBDIR>auto</UPLOADWEBDIR> 418 <CACHING>false</CACHING> 419 <SKIPLIFEVIEW>false</SKIPLIFEVIEW> 420 <DATAFIELD>data</DATAFIELD> 421 <RIGHTOVERRIDE>false</RIGHTOVERRIDE> 422 <LINKCHECK>1h</LINKCHECK> 423 <!-- 424 The Linkstyle can be any combination of path 425 with $id replaced by the id and $path replaced 426 by the absolute path to the document. 427 Binary files will be automatically converted to their 428 path 429 If you want to use the real index.jsp for preview add 430 &preview=true - this wil cause the cms taglib to use 431 the edit system (if rights suffice) 432 433 For multilanguage/tree stuff use $top[ID:"path"|ID2:"path2"|"defaultpath"] 434 ie: $top[0:"en"|121423:"de"|"fr"] 435 436 if you created the index.jsp with the corinis taglib you can use &preview=true 437 to enable preview mode 438 --> 439 <LINKSTYLE> 440 <PREVIEW>/corinis/modules/Cms/preview.jsp?Document_id=$id</PREVIEW> 441 <LIFE>/index.jsp?Document_id=$id</LIFE> 442 </LINKSTYLE> 443 444 <!-- 445 define the target for files: 446 INTERNAL: all internally linked documents 447 EXTERNAL: all external urls 448 FILES: all files (internal) 449 --> 450 <URLTARGET> 451 <INTERNAL /> 452 <EXTERNAL>_ext</EXTERNAL> 453 <FILES>_blank</FILES> 454 </URLTARGET> 455 456 <!-- Enable the QM System [default|fullqm] --> 457 <SYSTEM>default</SYSTEM> 458 459 </CMS> 460 461 <!-- 462 Document Manager Module 463 464 The uploaddir points to where the files will be stored. 465 --> 466 <DOCUMENTMANAGER> 467 <UPLOADDIR>auto</UPLOADDIR> 468 </DOCUMENTMANAGER> 469 470 <!-- 471 Forum Module 472 SUBSCRIBEEMAIL: the email address in the sent mail 473 SUBSCRIBEHEADER: the header of the message - you can use $name; $id; $title; 474 SUBSCRIBEBODY: path to a text file to be used as body, use $name; $id; $message; $title; in there 475 if BODY is set to auto the file WEB-INF/forumsubscribe.txt will be loaded 476 --> 477 <FORUM> 478 <SUBSCRIBEEMAIL>noreply@corinis.com</SUBSCRIBEEMAIL> 479 <SUBSCRIBENAME>noreply</SUBSCRIBENAME> 480 <SUBSCRIBESUBJECT>[Corinis Forum] New Forum Message: $title;</SUBSCRIBESUBJECT> 481 <SUBSCRIBEBODY>auto</SUBSCRIBEBODY> 482 </FORUM> 483 484 <!-- Webalbum Module --> 485 <PHOTOLIBRARY> 486 <IMAGEFOLDER>auto</IMAGEFOLDER> 487 <IMAGEWEBURL>auto</IMAGEWEBURL> 488 </PHOTOLIBRARY> 489 </MODULES> 490 490 </CORINIS> -
Core/trunk/pom.xml
r662 r690 1 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 2 <modelVersion>4.0.0</modelVersion> 3 <groupId>corinis.ccm</groupId> 4 <artifactId>Core</artifactId> 5 <version>4.0.0-SNAPSHOT</version> 6 <description>Corinis Core Module</description> 7 <dependencies> 8 <dependency> 9 <groupId>corinis.util</groupId> 10 <artifactId>corinis-xmlutil</artifactId> 11 <version>4.0.0-SNAPSHOT</version> 12 </dependency> 13 <dependency> 14 <groupId>javax.mail</groupId> 15 <artifactId>mail</artifactId> 16 <version>1.4.4</version> 17 </dependency> 18 <dependency> 19 <groupId>commons-fileupload</groupId> 20 <artifactId>commons-fileupload</artifactId> 21 <version>1.2.2</version> 22 </dependency> 23 <dependency> 24 <groupId>com.drewnoakes</groupId> 25 <artifactId>metadata-extractor</artifactId> 26 <version>2.4.0-beta-1</version> 27 </dependency> 28 <dependency> 29 <groupId>org.samba.jcifs</groupId> 30 <artifactId>jcifs</artifactId> 31 <version>1.3.14-kohsuke-1</version> 32 </dependency> 33 </dependencies> 34 <url>http://www.corinis.org/</url> 35 <name>Corinis</name> 36 <organization> 37 <name>Corinis</name> 38 <url>http://www.corinis.com</url> 39 </organization> 2 <modelVersion>4.0.0</modelVersion> 3 <groupId>corinis.ccm</groupId> 4 <artifactId>Core</artifactId> 5 <version>4.0.0-SNAPSHOT</version> 6 <description>Corinis Core Module</description> 7 <dependencies> 8 <dependency> 9 <groupId>corinis.util</groupId> 10 <artifactId>corinis-xmlutil</artifactId> 11 <version>4.0.0-SNAPSHOT</version> 12 </dependency> 13 <dependency> 14 <groupId>javax.mail</groupId> 15 <artifactId>mail</artifactId> 16 <version>1.4.4</version> 17 </dependency> 18 <dependency> 19 <groupId>commons-fileupload</groupId> 20 <artifactId>commons-fileupload</artifactId> 21 <version>1.2.2</version> 22 </dependency> 23 <dependency> 24 <groupId>com.drewnoakes</groupId> 25 <artifactId>metadata-extractor</artifactId> 26 <version>2.4.0-beta-1</version> 27 </dependency> 28 <dependency> 29 <groupId>org.samba.jcifs</groupId> 30 <artifactId>jcifs</artifactId> 31 <version>1.3.14-kohsuke-1</version> 32 </dependency> 33 </dependencies> 34 <build> 35 <plugins> 36 <plugin> 37 <groupId>org.apache.maven.plugins</groupId> 38 <artifactId>maven-compiler-plugin</artifactId> 39 <configuration> 40 <source>1.6</source> 41 <target>1.6</target> 42 <inputEncoding>${project.build.sourceEncoding}</inputEncoding> 43 </configuration> 44 </plugin> 45 </plugins> 46 </build> 47 48 <url>http://www.corinis.org/</url> 49 <name>Corinis</name> 50 <organization> 51 <name>Corinis</name> 52 <url>http://www.corinis.com</url> 53 </organization> 40 54 </project> -
Core/trunk/src/main/java/corinis/modules/AuthorityManager.java
r563 r690 35 35 36 36 public class AuthorityManager extends EntryManipulate implements IThrowsEvents, IProcessEvents{ 37 38 public FunctionAuthorityView authorityView; // function authorities39 public ElementAuthorityView rightsView; // element authorities40 41 public static final int RIGHTCREATE = 1;42 public static final int RIGHTMODIFY = 2;43 public static final int RIGHTVEW = 3;44 public static final int RIGHTDELETE = 4;45 public static final int RIGHTQM = 5;46 public static final int SPECIALRIGHT1 = 6;47 public static final int SPECIALRIGHT2 = 7;48 public static final int SPECIALRIGHT3 = 8;49 public static final int SPECIALRIGHT4 = 9;50 public static final int SPECIALRIGHT5 = 10;51 52 /**53 * Executes a call with an xml tree.54 *55 * @param root the call information56 * @param core.getDoc() the core.getDoc()ument57 * @return true if successfull58 */59 public Element callModule (Element root)60 {61 // get the function62 String func = DomUtil.getResultString(root, "FUNCTION");63 64 if ("createEntry".equalsIgnoreCase(func)) {65 authorityView.createEntry = true;66 return createEntry();67 } else if ("deleteEntry".equalsIgnoreCase(func))68 {69 authorityView.deleteEntry = true;70 return deleteEntry();71 // ignore catch72 }73 return null;74 }75 76 77 /**78 * function to get the Events which are thrown in the module.79 *80 * @return Event/Description String[][]81 */82 public String[][] getEvents() {83 String[][]s = new String[3][2];84 85 s[0][0] = "createEntry";86 s[0][1] = "Thrown when an authority is assigned to a user or group";87 88 s[1][0] = "getAuthorities";89 s[1][1] = "Thrown when the authorities are viewed";90 91 s[2][0] = "deleteEntry";92 s[2][1] = "Thrown when an authority is removed from a user or group";93 94 return s;95 }96 97 98 /**99 * function to get the Authorities needed for this module.100 *101 * @return Authority/Description String[][]102 */103 public String[][] getModuleAuthorities() {104 String[][] s = new String[4][2];105 106 s[0][0] = "AUTHORITY_CREATE";107 s[0][1] = "adding authorities to users or groups";108 109 s[1][0] = "AUTHORITY_DELETE";110 s[1][1] = "deletion of authorities";111 112 s[2][0] = "AUTHORITY_VIEW";113 s[2][1] = "viewing of current authorities";114 115 s[3][0] = "AUTHORITY_MODIFY";116 s[3][1] = "modify of authorities";117 return s;118 }119 120 /* (non-Javacore.getDoc())121 * @see corinis.modules.abstracts.Module#init(org.w3c.dom.Node)122 */123 protected void init(Node config) {124 authorityView = new FunctionAuthorityView(core);125 rightsView = new ElementAuthorityView(core);126 dataViews.add(authorityView);127 dataViews.add(rightsView);128 moduleName = "AuthorityManager";129 }130 131 132 133 /**134 * Constructor.135 * @param score <code>Core</code> the core class, has to be initialized first136 */137 public AuthorityManager(Core score) {138 super(score, "Core");139 }140 141 /**142 * Checks if the right request is a function authority request143 * @return true if the current request goes for function authority, false if for elementauthority144 */145 private boolean isFunctionAuthority ()146 {147 // a function authority request does not have AuthorityManager_module nor AuthorityManager_elementid148 if (rightsView.module == null && rightsView.elementid == -1)149 return true;150 // otherwise it is an element authority request151 return false;152 }153 154 /**155 * Creates an Element Authority / Function Authorities.156 * For function Authorities this is an update function for updating rights for users and groups<br>157 * Since this is done normally via checkboxes, we won't test what have changed<br>158 * but delete all authorities of the user or group and recreate them with what now<br>159 * should be the authorites (all that have been checked on).<br>160 * For element Authorities a simple element authority is created.<br>161 * <p>162 * <b>Authorities checked:</b>163 * AUTHORITY_CREATE<br>164 * <b>Request parameter:</b> <br>165 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br>166 * <i>AuthorityManager_user</i> - the userid of the user OR <br>167 * <i>AuthorityManager_group</i> - the groupid of the group<br>168 * <i>AuthorityManager_authority</i> - the authorities for the user or group (if functionauthority)<br>169 * <i>AuthorityManager_rightView</i> - if the View-Right is set (if elementauthority)<br>170 * <i>AuthorityManager_rightModify</i> - if the Modify-Right is set (if elementauthority)<br>171 * <i>AuthorityManager_rightDelete</i> - if the Delete-Right is set (if elementauthority)<br>172 * <i>AuthorityManager_rightCreate</i> - if the Create-Right is set (if elementauthority)<br>173 * <i>AuthorityManager_rightQm</i> - if the QM-Right is set (if elementauthority)<br>174 * <i>AuthorityManager_rightSpecial1</i> - if the Special1-Right is set (if elementauthority)<br>175 * <i>AuthorityManager_rightSpecial2</i> - if the Special2-Right is set (if elementauthority)<br>176 * <i>AuthorityManager_rightSpecial3</i> - if the Special3-Right is set (if elementauthority)<br>177 * <i>AuthorityManager_rightSpecial4</i> - if the Special4-Right is set (if elementauthority)<br>178 * <i>AuthorityManager_rightSpecial5</i> - if the Special5-Right is set (if elementauthority)<br>179 * <i>AuthorityManager_module</i> - the module of the elementauthority (if elementauthority)<br>180 * <i>AuthorityManager_elementid</i> - the id of the element (if elementauthority)<br>181 * <b>Possible Errors: </b> <br>182 * Authority missing<br>183 * Field missing <br>184 * Either a user or a group is needed<br>185 * Entry already exists<br>186 * </p>187 * <b>Return DOM</b><br>188 * <code><pre>189 * <AUTHORITY>190 * <RECREATEENTRY success="true">191 * <FIELDS>192 * </FIELDS>193 * </RECREATEENTRY>194 * </AUTHORITY>195 * </pre></code>196 *197 * @return the parsed xml return198 */199 200 public Element createEntry() {201 if (!authorityView.createEntry)202 return null;203 204 try {205 if ((!core.checkAuthority("AUTHORITY_CREATE", this)))206 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked());207 208 // no userid and no groupid -> error209 if (authorityView.userid < 0 && authorityView.groupid < 0) {210 ArrayList<String> al = new ArrayList<String>();211 al.add("userid");212 al.add("groupid");213 return eventer.nosuccess(Eventer.FIELD_MISSING, al);214 }215 216 // are we working with function or element authorites here217 if (isFunctionAuthority())218 {219 authorityView.startChange(this);220 221 // remove ALL authorities of this user/group and its descendants222 deleteAll(authorityView.userid, authorityView.groupid, authorityView);223 224 if (authorityView.authority != null)225 {226 if (authorityView.groupid > 0)227 {228 // create all authorities for the given group229 for (int i = 0; i < authorityView.authority.length; i++)230 createFunctionAuthority(authorityView.groupid, authorityView.authority[i], authorityView.userid, authorityView.groupid);231 // copy the authorities to the childs of the group232 copyAuthoritiesToChilds (authorityView.groupid, authorityView.authority);233 }234 else235 {236 // create all authorities for the given user237 for (int i = 0; i < authorityView.authority.length; i++)238 createFunctionAuthority(authorityView.groupid, authorityView.authority[i], authorityView.userid, authorityView.userid);239 }240 }241 authorityView.commitChange(this);242 }243 else244 {245 // Element Authority246 247 // defining the source248 long source = 0;249 if (authorityView.groupid > 0)250 source = authorityView.groupid;251 else252 source = authorityView.userid;253 254 if (!createEntry(rightsView.elementid, authorityView.userid, authorityView.groupid, rightsView.rightview, rightsView.rightcreate, rightsView.rightmodify, rightsView.rightdelete, rightsView.rightqm, rightsView.special1, rightsView.special2, rightsView.special3, rightsView.special4, rightsView.special5, rightsView.module, source, true))255 return eventer.nosuccess(Eventer.ENTRY_ALREADY_EXISTS, "User:"+authorityView.userid + ";Group:"+authorityView.groupid+";Element:"+rightsView.elementid+";Module:"+rightsView.module+";Source:"+source);256 257 // if it is a group - copy the authorities to the childs258 if (authorityView.groupid > 0)259 copyAuthorityToChilds (authorityView.groupid, rightsView.elementid, rightsView.rightview, rightsView.rightcreate, rightsView.rightmodify, rightsView.rightdelete, rightsView.rightqm, rightsView.special1, rightsView.special2, rightsView.special3, rightsView.special4, rightsView.special5, rightsView.module);260 }261 // reload cached Rights262 core.reloadRights();263 return eventer.success();264 } catch (Exception e) {265 eventer.fatalError(e.getMessage());266 e.printStackTrace();267 authorityView.rollbackChange(this);268 }269 return null;270 }271 272 private long id =0;273 274 /**275 * Helper function that returns an id (if the session context is unavailable)276 * @return a (hopefully) unique id277 */278 private long getId()279 {280 if (id == 0)281 id = System.currentTimeMillis();282 return id++;283 }284 285 286 /**287 * Creates a function authority.<br>288 * This function does no authority checking and is for internal use.289 *290 * @param group the group if group authority291 * @param authority the authority string292 * @param user the user if user authority293 * @param source the original source of the authority294 * @throws Exception295 */296 private void createFunctionAuthority(long group, String authority, long user, long source)297 {298 long id = -1;299 if (conf != null)300 {301 conf.clearStringCache(core);302 id = conf.getId();303 }304 else305 id = getId();306 307 Element iroot = core.getDoc().createElement("INSERT");308 309 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", id));310 if (user > 0)311 {312 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", user));313 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", -1));314 }315 else316 {317 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", group));318 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", -1));319 }320 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source));321 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHORITY", authority));322 323 authorityView.createEntry(pool, iroot);324 }325 326 /**327 * Creates a new Element Authority Entry. <br>328 *329 * @param elementid the id of the element330 * @param userid the id of the user331 * @param groupid the id of the group332 * @param rightview T/F für right to view333 * @param rightcreate T/F für right to create334 * @param rightmodify T/F für right to modify335 * @param rightdelete T/F für right to delete336 * @param rightqm T/F für right to qm337 * @param module Modulename338 * @param source source id where the authority comes from339 * @param check T/F for checking if the authority already exists (turn off for mass operations)340 *341 * @return true on success342 * @throws Exception343 */344 public boolean createEntry(long elementid, long userid, long groupid, boolean rightview, boolean rightcreate, boolean rightmodify, boolean rightdelete, boolean rightqm, boolean special1, boolean special2, boolean special3, boolean special4, boolean special5, String module, long source, boolean check) {345 if (conf != null)346 conf.clearRightCache(core);347 348 /**349 * @todo check if change right for the element - otherwise cmsright_create would be a globale right right350 */351 // check if already exists352 if (rightsView == null)353 rightsView = new ElementAuthorityView(core);354 355 if (check)356 {357 Element iroot = core.getDoc().createElement("SELECT");358 Element sfields = core.getDoc().createElement("FIELDS");359 iroot.appendChild(sfields);360 sfields.appendChild(core.getDoc().createElement("id"));361 Element wheres = core.getDoc().createElement("WHERE");362 iroot.appendChild(wheres);363 if (userid != -1)364 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", userid));365 else366 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", groupid));367 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "element", elementid));368 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module));369 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "source", source));370 Element results = rightsView.selectEntriesWhereClause(pool, iroot);371 372 if (results != null)373 return false;374 }375 376 long id;377 if (conf != null)378 id = conf.getId();379 else380 id = getId();381 Element iroot = core.getDoc().createElement("INSERT");382 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", String.valueOf(id)));383 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", elementid));384 if (userid != -1)385 {386 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", userid));387 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", -1));388 }389 else390 {391 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", groupid));392 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", -1));393 }394 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", rightview));395 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", rightcreate));396 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", rightmodify));397 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", rightdelete));398 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", rightqm));399 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", special1));400 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", special2));401 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", special3));402 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", special4));403 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", special5));404 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module));405 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source));406 rightsView.createEntry(pool, iroot);407 408 return true;409 }410 411 /**412 * Deletes all authorities for a user or group.413 * @param userid the userid414 * @param groupid the groupid415 * @param rightView the rightview (either ElementAuthorityView or FunctionAuthorityView)416 * @return true on success417 * @throws Exception if an error occurs418 */419 private boolean deleteAll(long userid, long groupid, DataView rightView)420 throws Exception {421 422 // deletes all unqely assigned authorities423 Element iroot = core.getDoc().createElement("DELETE");424 425 if (userid > 0)426 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", userid));427 else428 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", groupid));429 rightView.deleteEntry(pool, iroot);430 return true;431 }432 433 434 /**435 * Gets all authority / user and authority / group relations.436 * <br>437 * <p>438 * <b>Authorities checked:</b> AUTHORITY_VIEW<br>439 * <b>Request parameter:</b> <i>none</i><br>440 * <b>Possible Errors: </b> <br>441 * Authority missing<br>442 * </p>443 * <b>Return DOM</b><br>444 * <code><pre>445 * <AUTHORITIES>446 * <GROUPS>447 * <GROUP>448 * <ID>449 * <AUTHGROUP>450 * <DESCRIPTION>451 * </GROUP>452 * ...453 * </GROUPS>454 * <USERS>455 * <USER>456 * <ID>457 * <NAME>458 * </USER>459 * ....460 * </USERS>461 * <AVAILABLEAUTHORITIES>462 * <AUTHORITYBASE>463 * <AUTHORITY>464 * <DESCRIPTION>465 * <AUTHORITYBASE>466 * ....467 * <AVAILABLEAUTHORITIES>468 * <AUTHORITIES>469 * <GROUPAUTHORITY>470 * <GROUPID>471 * <GROUPNAME>472 * <AUTHORITY>473 * </GROUPAUTHORITY>474 * ...475 * <USERAUTHORITY>476 * <USERID>477 * <USERNAME>478 * <AUTHORITY>479 * </USERAUTHORITY>480 * ....481 * </AUTHORITIES>482 * </AUTHORITIES>483 * </pre></code>484 *485 * @return the groups, users, authorities, user/group - authority relations486 */487 488 public Element getEntries() {489 490 if (!core.checkAuthority("AUTHORITY_VIEW", this))491 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked());492 493 boolean userauth = true;494 495 // Start with the groups in resultstree496 Element root = core.getDoc().createElement("AUTHORITIES");497 Element posting;498 Element postings = core.getDoc().createElement("GROUPS");499 root.appendChild(postings);500 501 // Get the groups502 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core);503 Element iroot = core.getDoc().createElement("AUTHORITYUSERGROUP");504 Element results = authorityGroupView.selectEntries(pool, iroot);505 37 38 public FunctionAuthorityView authorityView; // function authorities 39 public ElementAuthorityView rightsView; // element authorities 40 41 public static final int RIGHTCREATE = 1; 42 public static final int RIGHTMODIFY = 2; 43 public static final int RIGHTVEW = 3; 44 public static final int RIGHTDELETE = 4; 45 public static final int RIGHTQM = 5; 46 public static final int SPECIALRIGHT1 = 6; 47 public static final int SPECIALRIGHT2 = 7; 48 public static final int SPECIALRIGHT3 = 8; 49 public static final int SPECIALRIGHT4 = 9; 50 public static final int SPECIALRIGHT5 = 10; 51 52 /** 53 * Executes a call with an xml tree. 54 * 55 * @param root the call information 56 * @param core.getDoc() the core.getDoc()ument 57 * @return true if successfull 58 */ 59 public Element callModule (Element root) 60 { 61 // get the function 62 String func = DomUtil.getResultString(root, "FUNCTION"); 63 64 if ("createEntry".equalsIgnoreCase(func)) { 65 authorityView.createEntry = true; 66 return createEntry(); 67 } else if ("deleteEntry".equalsIgnoreCase(func)) 68 { 69 authorityView.deleteEntry = true; 70 return deleteEntry(); 71 // ignore catch 72 } 73 return null; 74 } 75 76 77 /** 78 * function to get the Events which are thrown in the module. 79 * 80 * @return Event/Description String[][] 81 */ 82 public String[][] getEvents() { 83 String[][]s = new String[3][2]; 84 85 s[0][0] = "createEntry"; 86 s[0][1] = "Thrown when an authority is assigned to a user or group"; 87 88 s[1][0] = "getAuthorities"; 89 s[1][1] = "Thrown when the authorities are viewed"; 90 91 s[2][0] = "deleteEntry"; 92 s[2][1] = "Thrown when an authority is removed from a user or group"; 93 94 return s; 95 } 96 97 98 /** 99 * function to get the Authorities needed for this module. 100 * 101 * @return Authority/Description String[][] 102 */ 103 public String[][] getModuleAuthorities() { 104 String[][] s = new String[4][2]; 105 106 s[0][0] = "AUTHORITY_CREATE"; 107 s[0][1] = "adding authorities to users or groups"; 108 109 s[1][0] = "AUTHORITY_DELETE"; 110 s[1][1] = "deletion of authorities"; 111 112 s[2][0] = "AUTHORITY_VIEW"; 113 s[2][1] = "viewing of current authorities"; 114 115 s[3][0] = "AUTHORITY_MODIFY"; 116 s[3][1] = "modify of authorities"; 117 return s; 118 } 119 120 /* (non-Javacore.getDoc()) 121 * @see corinis.modules.abstracts.Module#init(org.w3c.dom.Node) 122 */ 123 protected void init(Node config) { 124 authorityView = new FunctionAuthorityView(core); 125 rightsView = new ElementAuthorityView(core); 126 dataViews.add(authorityView); 127 dataViews.add(rightsView); 128 moduleName = "AuthorityManager"; 129 } 130 131 132 133 /** 134 * Constructor. 135 * @param score <code>Core</code> the core class, has to be initialized first 136 */ 137 public AuthorityManager(Core score) { 138 super(score, "Core"); 139 } 140 141 /** 142 * Checks if the right request is a function authority request 143 * @return true if the current request goes for function authority, false if for elementauthority 144 */ 145 private boolean isFunctionAuthority () 146 { 147 // a function authority request does not have AuthorityManager_module nor AuthorityManager_elementid 148 if (rightsView.module == null && rightsView.elementid == -1) 149 return true; 150 // otherwise it is an element authority request 151 return false; 152 } 153 154 /** 155 * Creates an Element Authority / Function Authorities. 156 * For function Authorities this is an update function for updating rights for users and groups<br> 157 * Since this is done normally via checkboxes, we won't test what have changed<br> 158 * but delete all authorities of the user or group and recreate them with what now<br> 159 * should be the authorites (all that have been checked on).<br> 160 * For element Authorities a simple element authority is created.<br> 161 * <p> 162 * <b>Authorities checked:</b> 163 * AUTHORITY_CREATE<br> 164 * <b>Request parameter:</b> <br> 165 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br> 166 * <i>AuthorityManager_user</i> - the userid of the user OR <br> 167 * <i>AuthorityManager_group</i> - the groupid of the group<br> 168 * <i>AuthorityManager_authority</i> - the authorities for the user or group (if functionauthority)<br> 169 * <i>AuthorityManager_rightView</i> - if the View-Right is set (if elementauthority)<br> 170 * <i>AuthorityManager_rightModify</i> - if the Modify-Right is set (if elementauthority)<br> 171 * <i>AuthorityManager_rightDelete</i> - if the Delete-Right is set (if elementauthority)<br> 172 * <i>AuthorityManager_rightCreate</i> - if the Create-Right is set (if elementauthority)<br> 173 * <i>AuthorityManager_rightQm</i> - if the QM-Right is set (if elementauthority)<br> 174 * <i>AuthorityManager_rightSpecial1</i> - if the Special1-Right is set (if elementauthority)<br> 175 * <i>AuthorityManager_rightSpecial2</i> - if the Special2-Right is set (if elementauthority)<br> 176 * <i>AuthorityManager_rightSpecial3</i> - if the Special3-Right is set (if elementauthority)<br> 177 * <i>AuthorityManager_rightSpecial4</i> - if the Special4-Right is set (if elementauthority)<br> 178 * <i>AuthorityManager_rightSpecial5</i> - if the Special5-Right is set (if elementauthority)<br> 179 * <i>AuthorityManager_module</i> - the module of the elementauthority (if elementauthority)<br> 180 * <i>AuthorityManager_elementid</i> - the id of the element (if elementauthority)<br> 181 * <b>Possible Errors: </b> <br> 182 * Authority missing<br> 183 * Field missing <br> 184 * Either a user or a group is needed<br> 185 * Entry already exists<br> 186 * </p> 187 * <b>Return DOM</b><br> 188 * <code><pre> 189 * <AUTHORITY> 190 * <RECREATEENTRY success="true"> 191 * <FIELDS> 192 * </FIELDS> 193 * </RECREATEENTRY> 194 * </AUTHORITY> 195 * </pre></code> 196 * 197 * @return the parsed xml return 198 */ 199 200 public Element createEntry() { 201 if (!authorityView.createEntry) 202 return null; 203 204 try { 205 if ((!core.checkAuthority("AUTHORITY_CREATE", this))) 206 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked()); 207 208 // no userid and no groupid -> error 209 if (authorityView.userid < 0 && authorityView.groupid < 0) { 210 ArrayList<String> al = new ArrayList<String>(); 211 al.add("userid"); 212 al.add("groupid"); 213 return eventer.nosuccess(Eventer.FIELD_MISSING, al); 214 } 215 216 // are we working with function or element authorites here 217 if (isFunctionAuthority()) 218 { 219 authorityView.startChange(this); 220 221 // remove ALL authorities of this user/group and its descendants 222 deleteAll(authorityView.userid, authorityView.groupid, authorityView); 223 224 if (authorityView.authority != null) 225 { 226 if (authorityView.groupid > 0) 227 { 228 // create all authorities for the given group 229 for (int i = 0; i < authorityView.authority.length; i++) 230 createFunctionAuthority(authorityView.groupid, authorityView.authority[i], authorityView.userid, authorityView.groupid); 231 // copy the authorities to the childs of the group 232 copyAuthoritiesToChilds (authorityView.groupid, authorityView.authority); 233 } 234 else 235 { 236 // create all authorities for the given user 237 for (int i = 0; i < authorityView.authority.length; i++) 238 createFunctionAuthority(authorityView.groupid, authorityView.authority[i], authorityView.userid, authorityView.userid); 239 } 240 } 241 authorityView.commitChange(this); 242 } 243 else 244 { 245 // Element Authority 246 247 // defining the source 248 long source = 0; 249 if (authorityView.groupid > 0) 250 source = authorityView.groupid; 251 else 252 source = authorityView.userid; 253 254 if (!createEntry(rightsView.elementid, authorityView.userid, authorityView.groupid, rightsView.rightview, rightsView.rightcreate, rightsView.rightmodify, rightsView.rightdelete, rightsView.rightqm, rightsView.special1, rightsView.special2, rightsView.special3, rightsView.special4, rightsView.special5, rightsView.module, source, true)) 255 return eventer.nosuccess(Eventer.ENTRY_ALREADY_EXISTS, "User:"+authorityView.userid + ";Group:"+authorityView.groupid+";Element:"+rightsView.elementid+";Module:"+rightsView.module+";Source:"+source); 256 257 // if it is a group - copy the authorities to the childs 258 if (authorityView.groupid > 0) 259 copyAuthorityToChilds (authorityView.groupid, rightsView.elementid, rightsView.rightview, rightsView.rightcreate, rightsView.rightmodify, rightsView.rightdelete, rightsView.rightqm, rightsView.special1, rightsView.special2, rightsView.special3, rightsView.special4, rightsView.special5, rightsView.module); 260 } 261 // reload cached Rights 262 core.reloadRights(); 263 return eventer.success(); 264 } catch (Exception e) { 265 eventer.fatalError(e.getMessage()); 266 e.printStackTrace(); 267 authorityView.rollbackChange(this); 268 } 269 return null; 270 } 271 272 private long id =0; 273 274 /** 275 * Helper function that returns an id (if the session context is unavailable) 276 * @return a (hopefully) unique id 277 */ 278 private long getId() 279 { 280 if (id == 0) 281 id = System.currentTimeMillis(); 282 return id++; 283 } 284 285 286 /** 287 * Creates a function authority.<br> 288 * This function does no authority checking and is for internal use. 289 * 290 * @param group the group if group authority 291 * @param authority the authority string 292 * @param user the user if user authority 293 * @param source the original source of the authority 294 * @throws Exception 295 */ 296 private void createFunctionAuthority(long group, String authority, long user, long source) 297 { 298 long id = -1; 299 if (conf != null) 300 { 301 conf.clearStringCache(core); 302 id = conf.getId(); 303 } 304 else 305 id = getId(); 306 307 Element iroot = core.getDoc().createElement("INSERT"); 308 309 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", id)); 310 if (user > 0) 311 { 312 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", user)); 313 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", -1)); 314 } 315 else 316 { 317 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", group)); 318 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", -1)); 319 } 320 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source)); 321 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHORITY", authority)); 322 323 authorityView.createEntry(pool, iroot); 324 } 325 326 /** 327 * Creates a new Element Authority Entry. <br> 328 * 329 * @param elementid the id of the element 330 * @param userid the id of the user 331 * @param groupid the id of the group 332 * @param rightview T/F for right to view 333 * @param rightcreate T/F for right to create 334 * @param rightmodify T/F for right to modify 335 * @param rightdelete T/F for right to delete 336 * @param rightqm T/F for right to qm 337 * @param module Modulename 338 * @param source source id where the authority comes from 339 * @param check T/F for checking if the authority already exists (turn off for mass operations) 340 * 341 * @return true on success 342 * @throws Exception 343 */ 344 public boolean createEntry(long elementid, long userid, long groupid, boolean rightview, boolean rightcreate, boolean rightmodify, boolean rightdelete, boolean rightqm, boolean special1, boolean special2, boolean special3, boolean special4, boolean special5, String module, long source, boolean check) { 345 if (conf != null) 346 conf.clearRightCache(core); 347 348 /** 349 * @todo check if change right for the element - otherwise cmsright_create would be a globale right right 350 */ 351 // check if already exists 352 if (rightsView == null) 353 rightsView = new ElementAuthorityView(core); 354 355 if (check) 356 { 357 Element iroot = core.getDoc().createElement("SELECT"); 358 Element sfields = core.getDoc().createElement("FIELDS"); 359 iroot.appendChild(sfields); 360 sfields.appendChild(core.getDoc().createElement("id")); 361 Element wheres = core.getDoc().createElement("WHERE"); 362 iroot.appendChild(wheres); 363 if (userid != -1) 364 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", userid)); 365 else 366 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", groupid)); 367 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "element", elementid)); 368 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module)); 369 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "source", source)); 370 Element results = rightsView.selectEntriesWhereClause(pool, iroot); 371 372 if (results != null) 373 return false; 374 } 375 376 long id; 377 if (conf != null) 378 id = conf.getId(); 379 else 380 id = getId(); 381 Element iroot = core.getDoc().createElement("INSERT"); 382 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", String.valueOf(id))); 383 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", elementid)); 384 if (userid != -1) 385 { 386 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", userid)); 387 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", -1)); 388 } 389 else 390 { 391 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", groupid)); 392 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", -1)); 393 } 394 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", rightview)); 395 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", rightcreate)); 396 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", rightmodify)); 397 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", rightdelete)); 398 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", rightqm)); 399 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", special1)); 400 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", special2)); 401 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", special3)); 402 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", special4)); 403 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", special5)); 404 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module)); 405 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source)); 406 rightsView.createEntry(pool, iroot); 407 408 return true; 409 } 410 411 /** 412 * Deletes all authorities for a user or group. 413 * @param userid the userid 414 * @param groupid the groupid 415 * @param rightView the rightview (either ElementAuthorityView or FunctionAuthorityView) 416 * @return true on success 417 * @throws Exception if an error occurs 418 */ 419 private boolean deleteAll(long userid, long groupid, DataView rightView) 420 throws Exception { 421 422 // deletes all unqely assigned authorities 423 Element iroot = core.getDoc().createElement("DELETE"); 424 425 if (userid > 0) 426 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", userid)); 427 else 428 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", groupid)); 429 rightView.deleteEntry(pool, iroot); 430 return true; 431 } 432 433 434 /** 435 * Gets all authority / user and authority / group relations. 436 * <br> 437 * <p> 438 * <b>Authorities checked:</b> AUTHORITY_VIEW<br> 439 * <b>Request parameter:</b> <i>none</i><br> 440 * <b>Possible Errors: </b> <br> 441 * Authority missing<br> 442 * </p> 443 * <b>Return DOM</b><br> 444 * <code><pre> 445 * <AUTHORITIES> 446 * <GROUPS> 447 * <GROUP> 448 * <ID> 449 * <AUTHGROUP> 450 * <DESCRIPTION> 451 * </GROUP> 452 * ... 453 * </GROUPS> 454 * <USERS> 455 * <USER> 456 * <ID> 457 * <NAME> 458 * </USER> 459 * .... 460 * </USERS> 461 * <AVAILABLEAUTHORITIES> 462 * <AUTHORITYBASE> 463 * <AUTHORITY> 464 * <DESCRIPTION> 465 * <AUTHORITYBASE> 466 * .... 467 * <AVAILABLEAUTHORITIES> 468 * <AUTHORITIES> 469 * <GROUPAUTHORITY> 470 * <GROUPID> 471 * <GROUPNAME> 472 * <AUTHORITY> 473 * </GROUPAUTHORITY> 474 * ... 475 * <USERAUTHORITY> 476 * <USERID> 477 * <USERNAME> 478 * <AUTHORITY> 479 * </USERAUTHORITY> 480 * .... 481 * </AUTHORITIES> 482 * </AUTHORITIES> 483 * </pre></code> 484 * 485 * @return the groups, users, authorities, user/group - authority relations 486 */ 487 488 public Element getEntries() { 489 490 if (!core.checkAuthority("AUTHORITY_VIEW", this)) 491 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked()); 492 493 boolean userauth = true; 494 495 // Start with the groups in resultstree 496 Element root = core.getDoc().createElement("AUTHORITIES"); 497 Element posting; 498 Element postings = core.getDoc().createElement("GROUPS"); 499 root.appendChild(postings); 500 501 // Get the groups 502 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core); 503 Element iroot = core.getDoc().createElement("AUTHORITYUSERGROUP"); 504 Element results = authorityGroupView.selectEntries(pool, iroot); 505 506 506 for (Element cur : new ChildElementAdapter(results)) 507 507 { 508 posting = core.getDoc().createElement("GROUP");509 postings.appendChild(posting);510 511 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID")));512 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHGROUP", DomUtil.getResultString(cur, "AUTHGROUP")));513 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION")));514 }515 516 // Add Users Subtree517 postings = core.getDoc().createElement("USERS");518 root.appendChild(postings);519 520 // Get Users521 results = core.getUsers(pool, core.getDoc());522 508 posting = core.getDoc().createElement("GROUP"); 509 postings.appendChild(posting); 510 511 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID"))); 512 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHGROUP", DomUtil.getResultString(cur, "AUTHGROUP"))); 513 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION"))); 514 } 515 516 // Add Users Subtree 517 postings = core.getDoc().createElement("USERS"); 518 root.appendChild(postings); 519 520 // Get Users 521 results = core.getUsers(pool, core.getDoc()); 522 523 523 for (Element cur : new ChildElementAdapter(results)) 524 524 { 525 posting = core.getDoc().createElement("USER");526 postings.appendChild(posting);527 528 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "LOCALUSERID")));529 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", DomUtil.getResultString(cur, "LOCALUSERNAME")));530 }531 532 // Available Authorities533 postings = core.getDoc().createElement("AVAILABLEAUTHORITIES");534 root.appendChild(postings);535 536 // Get all valid authoritybases537 iroot = core.getDoc().createElement("AUTHORITY");538 Element wheres = core.getDoc().createElement("WHERE");539 iroot.appendChild(wheres);540 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "validity", "1"));541 results = new AuthorityBaseView(core).selectEntriesWhereClause(pool, iroot);542 525 posting = core.getDoc().createElement("USER"); 526 postings.appendChild(posting); 527 528 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "LOCALUSERID"))); 529 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", DomUtil.getResultString(cur, "LOCALUSERNAME"))); 530 } 531 532 // Available Authorities 533 postings = core.getDoc().createElement("AVAILABLEAUTHORITIES"); 534 root.appendChild(postings); 535 536 // Get all valid authoritybases 537 iroot = core.getDoc().createElement("AUTHORITY"); 538 Element wheres = core.getDoc().createElement("WHERE"); 539 iroot.appendChild(wheres); 540 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "validity", "1")); 541 results = new AuthorityBaseView(core).selectEntriesWhereClause(pool, iroot); 542 543 543 for (Element cur : new ChildElementAdapter(results)) 544 544 { 545 posting = core.getDoc().createElement("AUTHORITYBASE");546 postings.appendChild(posting);547 548 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID")));549 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHRORITY", DomUtil.getResultString(cur, "AUTHORITY")));550 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION")));551 }552 553 // Add Authorities subtree554 postings = core.getDoc().createElement("AUTHORITIES");555 root.appendChild(postings);556 557 558 iroot = core.getDoc().createElement("AUTHORITY");559 results = authorityView.selectEntries(pool, iroot);560 545 posting = core.getDoc().createElement("AUTHORITYBASE"); 546 postings.appendChild(posting); 547 548 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID"))); 549 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHRORITY", DomUtil.getResultString(cur, "AUTHORITY"))); 550 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION"))); 551 } 552 553 // Add Authorities subtree 554 postings = core.getDoc().createElement("AUTHORITIES"); 555 root.appendChild(postings); 556 557 558 iroot = core.getDoc().createElement("AUTHORITY"); 559 results = authorityView.selectEntries(pool, iroot); 560 561 561 for (Element cur : new ChildElementAdapter(results)) 562 562 { 563 if (DomUtil.getResultString(cur, "USERID") != null) {564 posting = core.getDoc().createElement("USERAUTHORITY");565 userauth = true;566 } else {567 posting = core.getDoc().createElement("GROUPAUTHORITY");568 userauth = false;569 }570 postings.appendChild(posting);571 572 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID")));573 574 if (userauth) {575 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", DomUtil.getResultString(cur, "USERID")));576 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "USERNAME", DomUtil.getResultString(cur, "USERNAME")));577 578 } else {579 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", DomUtil.getResultString(cur, "GROUPID")));580 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPNAME", DomUtil.getResultString(cur, "GROUPNAME")));581 }582 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHORITY", DomUtil.getResultString(cur, "AUTHORITY")));583 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", DomUtil.getResultString(cur, "SOURCE")));584 }585 return root;586 }587 588 589 /**590 * Deletes an element authority.591 * <br>592 * This is because createEntry for FunctionAuthorities is a recreate Function, deleting593 * all existing authorities and recreating them with the chosen function authorities.594 * <p>595 * <b>Authorities checked:</b> AUTHORITYMANAGER_DELETE<br>596 * <b>Request parameter:</b> <br>597 * <i>AuthorityManager_delete</i> - necessary to perform the function <br>598 * <i>AuthorityManager_id</i> - the id of the authority / user or authority / group relation to be deleted<br>599 * <b>Possible Errors: </b> <br>600 * Authority missing<br>601 * Field missing<br>602 * </p>603 * <b>Return DOM</b><br>604 * <code><pre>605 * <AUTHORITY>606 * <DELETEENTRY success="true">607 * <FIELDS>608 * </FIELDS>609 * </DELETEENTRY>610 * </AUTHORITY>611 * </pre></code>612 *613 * @return the parsed xml return614 */615 public Element deleteEntry ()616 {617 if (!authorityView.deleteEntry)618 return null;619 620 Element results;621 String[] parameter = { "id" };622 623 try624 {625 ArrayList<String> al = authorityView.generateVariableResponseTree(parameter);626 if (al != null)627 {628 return eventer.nosuccess(Eventer.FIELD_MISSING, al);629 }630 631 if ((!core.checkAuthority("AUTHORITY_DELETE", this)))632 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked());633 634 635 rightsView.startChange(this);636 637 long elementid = -1;638 String module = null;639 640 // Looking if group or user authority641 Element iroot = core.getDoc().createElement("SELECT");642 Element wheres = core.getDoc().createElement("WHERE");643 iroot.appendChild(wheres);644 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "id", rightsView.id));645 results = rightsView.selectEntriesWhereClause(pool, iroot);646 647 long userid = -1;648 long groupid = -1;649 if (results != null) {650 userid = DomUtil.getResultLong(results.getFirstChild(), "USERID");651 if (userid == -1)652 groupid = DomUtil.getResultLong(results.getFirstChild(), "GROUPID");653 elementid = DomUtil.getResultLong(results.getFirstChild(), "ELEMENT");654 module = DomUtil.getResultString(results.getFirstChild(), "MODULE");655 }656 657 iroot = core.getDoc().createElement("DELETE");658 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", rightsView.id));659 rightsView.deleteEntry(pool, iroot);660 661 if (groupid > 0)662 {663 // If group authority - Delete all also authorities in childs664 iroot = core.getDoc().createElement("DELETE");665 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", groupid));666 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", elementid));667 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module));668 rightsView.deleteEntry(pool, iroot);669 }670 671 rightsView.commitChange(this);672 673 // Reload cached authorities674 if (conf != null)675 conf.clearRightCache(core);676 core.reloadRights();677 678 return eventer.success();679 680 } catch (Exception e) {681 eventer.fatalError(e.getMessage());682 e.printStackTrace();683 rightsView.rollbackChange(this);684 }685 return null;686 }687 688 689 /**690 * Gets the rights of a specific element.691 * <br>692 * <p>693 * <b>Authorities checked:</b>694 * ELEMENT_AUTHORITYMANAGER_VIEW<br>695 * <b>Request parameter:</b> <br>696 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br>697 * <i>AuthorityManager_elementid</i> - the id of the element<br>698 * <i>AuthorityManager_module</i> - the module of the element (i.e. CMS)<br>699 * <b>Possible Errors: </b> <br>700 * Authority missing<br>701 * Field missing <br>702 * </p>703 * <b>Return DOM</b><br>704 * <code><pre>705 * <CMSRIGHTMANAGER>706 * <MODULE>themodule</MODULE>707 * <GROUPS>708 * <GROUP>709 * <ID>710 * <AUTHGROUP>711 * <DESCRIPTION>712 * </GROUP>713 * ...714 * </GROUPS>715 * <USERS>716 * <USER>717 * <ID/>718 * <NAME/>719 * </USER>720 * </USERS>721 * <RIGHTS>722 * <RIGHT>723 * <ID/>724 * <NAME/> or <GROUPNAME/>725 * <RIGHTVIEW/>726 * <RIGHTDELETE/>727 * <RIGHTCREATE/>728 * <RIGHTMODIFY/>729 * <RIGHTQM/>730 * <SPECIALRIGHT1/>731 * <SPECIALRIGHT2/>732 * <SPECIALRIGHT3/>733 * <SPECIALRIGHT4/>734 * <SPECIALRIGHT5/>735 * <SOURCE/>736 * </RIGHT>737 * ...738 * </RIGHTS>739 * </CMSRIGHTMANAGER>740 * </pre></code>741 *742 * @return the parsed xml return743 */744 public Element getEntry() {745 String[] parameter = { "elementid", "module"};746 747 try {748 ArrayList<String> al = rightsView.generateVariableResponseTree(parameter);749 if (al != null) {750 return eventer.nosuccess(Eventer.FIELD_MISSING, al);751 }752 if (!core.checkAuthority("AUTHORITY_VIEW", this)) {753 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked());754 }755 756 Element postings, posting, results = null;757 758 Element root = core.getDoc().createElement("CMSRIGHTMANAGER");759 root.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", rightsView.module));760 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core);761 762 // Get groups763 postings = core.getDoc().createElement("GROUPS");764 root.appendChild(postings);765 Element iroot = core.getDoc().createElement("AUTHORITYUSERGROUP");766 results = authorityGroupView.selectEntries(pool, iroot);767 for (Element cur : new ChildElementAdapter(results))768 {769 posting = core.getDoc().createElement("GROUP");770 postings.appendChild(posting);771 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID")));772 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHGROUP", DomUtil.getResultString(cur, "AUTHGROUP")));773 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION")));774 }775 // Get Users776 postings = core.getDoc().createElement("USERS");777 root.appendChild(postings);778 results = core.getUsers(pool, core.getDoc());779 for (Element cur : new ChildElementAdapter(results))780 {781 posting = core.getDoc().createElement("USER");782 postings.appendChild(posting);783 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "LOCALUSERID")));784 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", DomUtil.getResultString(cur, "LOCALUSERNAME")));785 }786 postings = core.getDoc().createElement("RIGHTS");787 root.appendChild(postings);788 iroot = core.getDoc().createElement("SELECT");789 Element wheres = core.getDoc().createElement("WHERE");790 iroot.appendChild(wheres);791 Element and = core.getDoc().createElement("AND");792 wheres.appendChild(and);793 and.appendChild(DomUtil.CreateNode(core.getDoc(), "element", rightsView.elementid));794 and.appendChild(DomUtil.CreateNode(core.getDoc(), "module", rightsView.module));795 Element or = core.getDoc().createElement("OR");796 and.appendChild(or);797 or.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "groupid"));798 or.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "userid"));799 results = rightsView.selectEntriesWhereExtended(pool, iroot);800 for (Element cur : new ChildElementAdapter(results))801 {802 posting = core.getDoc().createElement("RIGHT");803 postings.appendChild(posting);804 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID")));805 if (DomUtil.getResultString(cur, "USERID") != null && !DomUtil.getResultString(cur, "USERID").equals("") && DomUtil.getResultLong(cur, "USERID") !=-1 )806 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", core.getUserById(DomUtil.getResultLong(cur, "USERID"))));807 else808 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPNAME", core.getAuthorityGroupByID(Utils.parseLong(DomUtil.getResultString(cur, "GROUPID")))));809 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", DomUtil.getResultString(cur, "RIGHTVIEW")));810 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", DomUtil.getResultString(cur, "RIGHTCREATE")));811 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", DomUtil.getResultString(cur, "RIGHTMODIFY")));812 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", DomUtil.getResultString(cur, "RIGHTDELETE")));813 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", DomUtil.getResultString(cur, "RIGHTQM")));814 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", DomUtil.getResultString(cur, "SPECIALRIGHT1")));815 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", DomUtil.getResultString(cur, "SPECIALRIGHT2")));816 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", DomUtil.getResultString(cur, "SPECIALRIGHT3")));817 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", DomUtil.getResultString(cur, "SPECIALRIGHT4")));818 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", DomUtil.getResultString(cur, "SPECIALRIGHT5")));819 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", core.getAuthorityGroupByID(DomUtil.getResultLong(cur, "SOURCE"))));820 }821 postings = core.getDoc().createElement("ELEMENT");822 root.appendChild(postings);823 postings.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", rightsView.elementid));824 825 eventer.success();826 return root;827 } catch (Exception e) {828 System.err.println("Fatal Database error " + e.toString());829 e.printStackTrace();830 }831 return null;832 }833 834 563 if (DomUtil.getResultString(cur, "USERID") != null) { 564 posting = core.getDoc().createElement("USERAUTHORITY"); 565 userauth = true; 566 } else { 567 posting = core.getDoc().createElement("GROUPAUTHORITY"); 568 userauth = false; 569 } 570 postings.appendChild(posting); 571 572 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID"))); 573 574 if (userauth) { 575 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "USERID", DomUtil.getResultString(cur, "USERID"))); 576 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "USERNAME", DomUtil.getResultString(cur, "USERNAME"))); 577 578 } else { 579 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPID", DomUtil.getResultString(cur, "GROUPID"))); 580 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPNAME", DomUtil.getResultString(cur, "GROUPNAME"))); 581 } 582 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHORITY", DomUtil.getResultString(cur, "AUTHORITY"))); 583 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", DomUtil.getResultString(cur, "SOURCE"))); 584 } 585 return root; 586 } 587 588 589 /** 590 * Deletes an element authority. 591 * <br> 592 * This is because createEntry for FunctionAuthorities is a recreate Function, deleting 593 * all existing authorities and recreating them with the chosen function authorities. 594 * <p> 595 * <b>Authorities checked:</b> AUTHORITYMANAGER_DELETE<br> 596 * <b>Request parameter:</b> <br> 597 * <i>AuthorityManager_delete</i> - necessary to perform the function <br> 598 * <i>AuthorityManager_id</i> - the id of the authority / user or authority / group relation to be deleted<br> 599 * <b>Possible Errors: </b> <br> 600 * Authority missing<br> 601 * Field missing<br> 602 * </p> 603 * <b>Return DOM</b><br> 604 * <code><pre> 605 * <AUTHORITY> 606 * <DELETEENTRY success="true"> 607 * <FIELDS> 608 * </FIELDS> 609 * </DELETEENTRY> 610 * </AUTHORITY> 611 * </pre></code> 612 * 613 * @return the parsed xml return 614 */ 615 public Element deleteEntry () 616 { 617 if (!authorityView.deleteEntry) 618 return null; 619 620 Element results; 621 String[] parameter = { "id" }; 622 623 try 624 { 625 ArrayList<String> al = authorityView.generateVariableResponseTree(parameter); 626 if (al != null) 627 { 628 return eventer.nosuccess(Eventer.FIELD_MISSING, al); 629 } 630 631 if ((!core.checkAuthority("AUTHORITY_DELETE", this))) 632 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked()); 633 634 635 rightsView.startChange(this); 636 637 long elementid = -1; 638 String module = null; 639 640 // Looking if group or user authority 641 Element iroot = core.getDoc().createElement("SELECT"); 642 Element wheres = core.getDoc().createElement("WHERE"); 643 iroot.appendChild(wheres); 644 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "id", rightsView.id)); 645 results = rightsView.selectEntriesWhereClause(pool, iroot); 646 647 long userid = -1; 648 long groupid = -1; 649 if (results != null) { 650 userid = DomUtil.getResultLong(results.getFirstChild(), "USERID"); 651 if (userid == -1) 652 groupid = DomUtil.getResultLong(results.getFirstChild(), "GROUPID"); 653 elementid = DomUtil.getResultLong(results.getFirstChild(), "ELEMENT"); 654 module = DomUtil.getResultString(results.getFirstChild(), "MODULE"); 655 } 656 657 iroot = core.getDoc().createElement("DELETE"); 658 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", rightsView.id)); 659 rightsView.deleteEntry(pool, iroot); 660 661 if (groupid > 0) 662 { 663 // If group authority - Delete all also authorities in childs 664 iroot = core.getDoc().createElement("DELETE"); 665 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", groupid)); 666 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", elementid)); 667 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module)); 668 rightsView.deleteEntry(pool, iroot); 669 } 670 671 rightsView.commitChange(this); 672 673 // Reload cached authorities 674 if (conf != null) 675 conf.clearRightCache(core); 676 core.reloadRights(); 677 678 return eventer.success(); 679 680 } catch (Exception e) { 681 eventer.fatalError(e.getMessage()); 682 e.printStackTrace(); 683 rightsView.rollbackChange(this); 684 } 685 return null; 686 } 687 688 689 /** 690 * Gets the rights of a specific element. 691 * <br> 692 * <p> 693 * <b>Authorities checked:</b> 694 * ELEMENT_AUTHORITYMANAGER_VIEW<br> 695 * <b>Request parameter:</b> <br> 696 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br> 697 * <i>AuthorityManager_elementid</i> - the id of the element<br> 698 * <i>AuthorityManager_module</i> - the module of the element (i.e. CMS)<br> 699 * <b>Possible Errors: </b> <br> 700 * Authority missing<br> 701 * Field missing <br> 702 * </p> 703 * <b>Return DOM</b><br> 704 * <code><pre> 705 * <CMSRIGHTMANAGER> 706 * <MODULE>themodule</MODULE> 707 * <GROUPS> 708 * <GROUP> 709 * <ID> 710 * <AUTHGROUP> 711 * <DESCRIPTION> 712 * </GROUP> 713 * ... 714 * </GROUPS> 715 * <USERS> 716 * <USER> 717 * <ID/> 718 * <NAME/> 719 * </USER> 720 * </USERS> 721 * <RIGHTS> 722 * <RIGHT> 723 * <ID/> 724 * <NAME/> or <GROUPNAME/> 725 * <RIGHTVIEW/> 726 * <RIGHTDELETE/> 727 * <RIGHTCREATE/> 728 * <RIGHTMODIFY/> 729 * <RIGHTQM/> 730 * <SPECIALRIGHT1/> 731 * <SPECIALRIGHT2/> 732 * <SPECIALRIGHT3/> 733 * <SPECIALRIGHT4/> 734 * <SPECIALRIGHT5/> 735 * <SOURCE/> 736 * </RIGHT> 737 * ... 738 * </RIGHTS> 739 * </CMSRIGHTMANAGER> 740 * </pre></code> 741 * 742 * @return the parsed xml return 743 */ 744 public Element getEntry() { 745 String[] parameter = { "elementid", "module"}; 746 747 try { 748 ArrayList<String> al = rightsView.generateVariableResponseTree(parameter); 749 if (al != null) { 750 return eventer.nosuccess(Eventer.FIELD_MISSING, al); 751 } 752 if (!core.checkAuthority("AUTHORITY_VIEW", this)) { 753 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked()); 754 } 755 756 Element postings, posting, results = null; 757 758 Element root = core.getDoc().createElement("CMSRIGHTMANAGER"); 759 root.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", rightsView.module)); 760 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core); 761 762 // Get groups 763 postings = core.getDoc().createElement("GROUPS"); 764 root.appendChild(postings); 765 Element iroot = core.getDoc().createElement("AUTHORITYUSERGROUP"); 766 results = authorityGroupView.selectEntries(pool, iroot); 767 for (Element cur : new ChildElementAdapter(results)) 768 { 769 posting = core.getDoc().createElement("GROUP"); 770 postings.appendChild(posting); 771 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID"))); 772 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "AUTHGROUP", DomUtil.getResultString(cur, "AUTHGROUP"))); 773 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "DESCRIPTION", DomUtil.getResultString(cur, "DESCRIPTION"))); 774 } 775 // Get Users 776 postings = core.getDoc().createElement("USERS"); 777 root.appendChild(postings); 778 results = core.getUsers(pool, core.getDoc()); 779 for (Element cur : new ChildElementAdapter(results)) 780 { 781 posting = core.getDoc().createElement("USER"); 782 postings.appendChild(posting); 783 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "LOCALUSERID"))); 784 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", DomUtil.getResultString(cur, "LOCALUSERNAME"))); 785 } 786 postings = core.getDoc().createElement("RIGHTS"); 787 root.appendChild(postings); 788 iroot = core.getDoc().createElement("SELECT"); 789 Element wheres = core.getDoc().createElement("WHERE"); 790 iroot.appendChild(wheres); 791 Element and = core.getDoc().createElement("AND"); 792 wheres.appendChild(and); 793 and.appendChild(DomUtil.CreateNode(core.getDoc(), "element", rightsView.elementid)); 794 and.appendChild(DomUtil.CreateNode(core.getDoc(), "module", rightsView.module)); 795 Element or = core.getDoc().createElement("OR"); 796 and.appendChild(or); 797 or.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "groupid")); 798 or.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "userid")); 799 results = rightsView.selectEntriesWhereExtended(pool, iroot); 800 for (Element cur : new ChildElementAdapter(results)) 801 { 802 posting = core.getDoc().createElement("RIGHT"); 803 postings.appendChild(posting); 804 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", DomUtil.getResultString(cur, "ID"))); 805 if (DomUtil.getResultString(cur, "USERID") != null && !DomUtil.getResultString(cur, "USERID").equals("") && DomUtil.getResultLong(cur, "USERID") !=-1 ) 806 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "NAME", core.getUserById(DomUtil.getResultLong(cur, "USERID")))); 807 else 808 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "GROUPNAME", core.getAuthorityGroupByID(Utils.parseLong(DomUtil.getResultString(cur, "GROUPID"))))); 809 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", DomUtil.getResultString(cur, "RIGHTVIEW"))); 810 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", DomUtil.getResultString(cur, "RIGHTCREATE"))); 811 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", DomUtil.getResultString(cur, "RIGHTMODIFY"))); 812 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", DomUtil.getResultString(cur, "RIGHTDELETE"))); 813 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", DomUtil.getResultString(cur, "RIGHTQM"))); 814 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", DomUtil.getResultString(cur, "SPECIALRIGHT1"))); 815 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", DomUtil.getResultString(cur, "SPECIALRIGHT2"))); 816 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", DomUtil.getResultString(cur, "SPECIALRIGHT3"))); 817 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", DomUtil.getResultString(cur, "SPECIALRIGHT4"))); 818 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", DomUtil.getResultString(cur, "SPECIALRIGHT5"))); 819 posting.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", core.getAuthorityGroupByID(DomUtil.getResultLong(cur, "SOURCE")))); 820 } 821 postings = core.getDoc().createElement("ELEMENT"); 822 root.appendChild(postings); 823 postings.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", rightsView.elementid)); 824 825 eventer.success(); 826 return root; 827 } catch (Exception e) { 828 System.err.println("Fatal Database error " + e.toString()); 829 e.printStackTrace(); 830 } 831 return null; 832 } 833 834 835 835 /** 836 836 * Returns all the childgroups of the group in an arraylist. … … 840 840 private ArrayList<Long> getGroupChilds(long groupid) 841 841 { 842 AuthorityUserGroupView authorityUserGroupView = new AuthorityUserGroupView(core);843 ArrayList<Long> groupchilds = new ArrayList<Long>();844 ArrayList<Long> childs = new ArrayList<Long>();845 Element results = null;846 847 Element iroot = core.getDoc().createElement("SELECT");848 Element fields = core.getDoc().createElement("FIELDS");849 iroot.appendChild(fields);850 fields.appendChild(core.getDoc().createElement("groupid"));851 Element wheres = core.getDoc().createElement("WHERE");852 853 iroot.appendChild(wheres);854 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", groupid));855 856 results = authorityUserGroupView.selectEntriesWhereClause(pool, iroot);857 858 try {859 for (Element cur : new ChildElementAdapter(results))860 {861 long gid = DomUtil.getResultLong(cur, "groupid");862 if (gid != -1)863 {864 groupchilds.add(new Long(gid));865 childs.add(new Long(gid));866 }867 }868 869 // Search for childgroups870 for (int j = 0; groupchilds != null && j < groupchilds.size(); j++) {871 ArrayList<Long> childgroups = getGroupChilds(groupchilds.get(j));872 873 for (int z = 0; childgroups != null && z < childgroups.size(); z++)874 childs.add(childgroups.get(z));875 }876 } catch (Exception e) {877 e.printStackTrace();878 }879 return childs;880 881 } 882 883 884 /**885 * Change an Entry (Element Authority only!).886 * <p>887 * <b>Authorities checked:</b>888 * AUTHORITY_MODIFY<br>889 * <b>Request parameter:</b> <br>890 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br>891 * <i>AuthorityManager_elementid</i> - the id of the element<br>892 * <i>AuthorityManager_module</i> - the module of the element<br>893 * <i>AuthorityManager_rightView</i> - if the View-Right is set<br>894 * <i>AuthorityManager_rightModify</i> - if the Modify-Right is set<br>895 * <i>AuthorityManager_rightDelete</i> - if the Delete-Right is set<br>896 * <i>AuthorityManager_rightCreate</i> - if the Create-Right is set<br>897 * <i>AuthorityManager_rightQm</i> - if the QM-Right is set<br>898 * <i>AuthorityManager_rightSpecial1</i> - if the Special1-Right is set<br>899 * <i>AuthorityManager_rightSpecial2</i> - if the Special2-Right is set<br>900 * <i>AuthorityManager_rightSpecial3</i> - if the Special3-Right is set<br>901 * <i>AuthorityManager_rightSpecial4</i> - if the Special4-Right is set<br>902 * <i>AuthorityManager_rightSpecial5</i> - if the Special5-Right is set <br>903 * <b>Possible Errors: </b> <br>904 * Authority missing<br>905 * Field missing <br>906 * </p>907 * <b>Return DOM</b><br>908 * Standard Return Tree909 *910 * @return the parsed xml return911 */912 913 914 public Element modifyEntry() {915 if (!authorityView.modifyEntry)916 return null;917 String[] parameter = { "id"};918 919 String module = null;920 long elementid = -1;921 long groupid = -1;922 long userid = -1;923 924 try {925 ArrayList<String> al = moduleData.generateVariableResponseTree(parameter);926 if (al != null) {927 return eventer.nosuccess(Eventer.FIELD_MISSING, al);928 }929 if (!core.checkAuthority("AUTHORITY_MODIFY", this)) {930 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked());931 }932 933 // Get the element934 Element iroot = core.getDoc().createElement("SELECT");935 Element sfields = core.getDoc().createElement("FIELDS");936 iroot.appendChild(sfields);937 sfields.appendChild(core.getDoc().createElement("element"));938 sfields.appendChild(core.getDoc().createElement("module"));939 sfields.appendChild(core.getDoc().createElement("userid"));940 sfields.appendChild(core.getDoc().createElement("groupid"));941 Element wheres = core.getDoc().createElement("WHERE");942 iroot.appendChild(wheres);943 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "id", rightsView.id));944 945 Element results = rightsView.selectEntriesWhereClause(pool, iroot);946 947 if (results != null) {948 949 Element cur = (Element)results.getFirstChild();950 module = DomUtil.getResultString(results.getFirstChild(), "MODULE");951 elementid = DomUtil.getResultLong(results.getFirstChild(), "ELEMENT");952 long source = 0;953 userid = DomUtil.getResultLong(cur, "USERID");954 if (userid != -1)955 {956 source = userid;957 }958 else959 {960 groupid = DomUtil.getResultLong(cur, "GROUPID");961 source = groupid;962 }963 964 // Allow Modify only if the user has the authority965 if (core.rightModify(elementid, module)) {966 967 iroot = core.getDoc().createElement("UPDATE");968 Element set = core.getDoc().createElement("SET");969 iroot.appendChild(set);970 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", rightsView.rightview));971 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", rightsView.rightcreate));972 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", rightsView.rightmodify));973 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", rightsView.rightdelete));974 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", rightsView.rightqm));975 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", rightsView.special1));976 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", rightsView.special2));977 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", rightsView.special3));978 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", rightsView.special4));979 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", rightsView.special5));980 981 wheres = core.getDoc().createElement("WHERE");982 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module));983 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", rightsView.elementid));984 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source));985 iroot.appendChild(wheres);986 rightsView.updateEntryWhereClause(pool, iroot);987 988 }989 // Reload cached authorities990 core.reloadRights();991 if (conf != null)992 conf.clearRightCache(core);993 return (eventer.success());994 }995 return eventer.nosuccess(Eventer.ENTRY_NOT_EXIST, String.valueOf(rightsView.id));996 997 } catch (Exception e) {998 eventer.fatalError(e.getMessage());999 e.printStackTrace();1000 }1001 return null;1002 }1003 1004 1005 /**1006 * Copies the authorities in the array to the childs of the group.1007 * @param groupid the parent group to which childs the authorities should be copied1008 * @param authorities the String[] of authorities1009 */1010 private void copyAuthoritiesToChilds (long groupid, String[] authorities)1011 {1012 //Search for all childs of the group1013 ArrayList<Long> groups = getGroupChilds(groupid);1014 1015 for (int j = 0; groups != null && j < groups.size(); j++)1016 {1017 // create the authorities for all childgroups1018 for (int i = 0; i < authorities.length; i++)1019 this.createFunctionAuthority(((Long)groups.get(j)).longValue(), authorities[i], -1, groupid);1020 }1021 }1022 1023 1024 /**1025 * Copies the given authorities to all childs of the group.1026 * @param groupid the groupid to which childs the authority is1027 * @param elementid1028 * @param rightview1029 * @param rightcreate1030 * @param rightmodify1031 * @param rightdelete1032 * @param rightqm1033 * @param special11034 * @param special21035 * @param special31036 * @param special41037 * @param special51038 * @param module1039 */1040 private void copyAuthorityToChilds (long groupid, long elementid, boolean rightview, boolean rightcreate, boolean rightmodify, boolean rightdelete, boolean rightqm, boolean special1, boolean special2, boolean special3, boolean special4, boolean special5, String module)1041 {1042 1043 //groups1044 ArrayList<Long> groups = getGroupChilds(groupid);1045 //ArrayList users = null;1046 for (int j = 0; groups != null && j < groups.size(); j++)1047 {1048 this.createEntry(elementid,1049 -1,1050 ((Long)groups.get(j)).longValue(),1051 rightview,1052 rightcreate,1053 rightmodify,1054 rightdelete,1055 rightqm,1056 special1,1057 special2,1058 special3,1059 special4,1060 special5,1061 module,1062 groupid,1063 false);1064 }1065 }1066 1067 /**1068 * Copies all function authorites of the group to all the groups in the Arraylist.1069 * @param group the group where to copy the authorities from1070 * @param childgroups the childgroups in an ArrayList1071 */1072 protected void copyFunctionAuthoritiesToGroups (long group, ArrayList<Long> childgroups)1073 {1074 // Get the authorities of the group1075 Element iroot = core.getDoc().createElement("SELECT");1076 Element wheres = core.getDoc().createElement("WHERE");1077 iroot.appendChild(wheres);1078 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", group));1079 1080 Element results = authorityView.selectEntriesWhereClause(pool, iroot);842 AuthorityUserGroupView authorityUserGroupView = new AuthorityUserGroupView(core); 843 ArrayList<Long> groupchilds = new ArrayList<Long>(); 844 ArrayList<Long> childs = new ArrayList<Long>(); 845 Element results = null; 846 847 Element iroot = core.getDoc().createElement("SELECT"); 848 Element fields = core.getDoc().createElement("FIELDS"); 849 iroot.appendChild(fields); 850 fields.appendChild(core.getDoc().createElement("groupid")); 851 Element wheres = core.getDoc().createElement("WHERE"); 852 853 iroot.appendChild(wheres); 854 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", groupid)); 855 856 results = authorityUserGroupView.selectEntriesWhereClause(pool, iroot); 857 858 try { 859 for (Element cur : new ChildElementAdapter(results)) 860 { 861 long gid = DomUtil.getResultLong(cur, "groupid"); 862 if (gid != -1) 863 { 864 groupchilds.add(new Long(gid)); 865 childs.add(new Long(gid)); 866 } 867 } 868 869 // Search for childgroups 870 for (int j = 0; groupchilds != null && j < groupchilds.size(); j++) { 871 ArrayList<Long> childgroups = getGroupChilds(groupchilds.get(j)); 872 873 for (int z = 0; childgroups != null && z < childgroups.size(); z++) 874 childs.add(childgroups.get(z)); 875 } 876 } catch (Exception e) { 877 e.printStackTrace(); 878 } 879 return childs; 880 881 } 882 883 884 /** 885 * Change an Entry (Element Authority only!). 886 * <p> 887 * <b>Authorities checked:</b> 888 * AUTHORITY_MODIFY<br> 889 * <b>Request parameter:</b> <br> 890 * <i>AuthorityManager_createEntry</i> - necessary to perform the function<br> 891 * <i>AuthorityManager_elementid</i> - the id of the element<br> 892 * <i>AuthorityManager_module</i> - the module of the element<br> 893 * <i>AuthorityManager_rightView</i> - if the View-Right is set<br> 894 * <i>AuthorityManager_rightModify</i> - if the Modify-Right is set<br> 895 * <i>AuthorityManager_rightDelete</i> - if the Delete-Right is set<br> 896 * <i>AuthorityManager_rightCreate</i> - if the Create-Right is set<br> 897 * <i>AuthorityManager_rightQm</i> - if the QM-Right is set<br> 898 * <i>AuthorityManager_rightSpecial1</i> - if the Special1-Right is set<br> 899 * <i>AuthorityManager_rightSpecial2</i> - if the Special2-Right is set<br> 900 * <i>AuthorityManager_rightSpecial3</i> - if the Special3-Right is set<br> 901 * <i>AuthorityManager_rightSpecial4</i> - if the Special4-Right is set<br> 902 * <i>AuthorityManager_rightSpecial5</i> - if the Special5-Right is set <br> 903 * <b>Possible Errors: </b> <br> 904 * Authority missing<br> 905 * Field missing <br> 906 * </p> 907 * <b>Return DOM</b><br> 908 * Standard Return Tree 909 * 910 * @return the parsed xml return 911 */ 912 913 914 public Element modifyEntry() { 915 if (!authorityView.modifyEntry) 916 return null; 917 String[] parameter = { "id"}; 918 919 String module = null; 920 long elementid = -1; 921 long groupid = -1; 922 long userid = -1; 923 924 try { 925 ArrayList<String> al = moduleData.generateVariableResponseTree(parameter); 926 if (al != null) { 927 return eventer.nosuccess(Eventer.FIELD_MISSING, al); 928 } 929 if (!core.checkAuthority("AUTHORITY_MODIFY", this)) { 930 return eventer.nosuccess(Eventer.AUTHORITY_MISSING,this.getLastAuthorityChecked()); 931 } 932 933 // Get the element 934 Element iroot = core.getDoc().createElement("SELECT"); 935 Element sfields = core.getDoc().createElement("FIELDS"); 936 iroot.appendChild(sfields); 937 sfields.appendChild(core.getDoc().createElement("element")); 938 sfields.appendChild(core.getDoc().createElement("module")); 939 sfields.appendChild(core.getDoc().createElement("userid")); 940 sfields.appendChild(core.getDoc().createElement("groupid")); 941 Element wheres = core.getDoc().createElement("WHERE"); 942 iroot.appendChild(wheres); 943 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "id", rightsView.id)); 944 945 Element results = rightsView.selectEntriesWhereClause(pool, iroot); 946 947 if (results != null) { 948 949 Element cur = (Element)results.getFirstChild(); 950 module = DomUtil.getResultString(results.getFirstChild(), "MODULE"); 951 elementid = DomUtil.getResultLong(results.getFirstChild(), "ELEMENT"); 952 long source = 0; 953 userid = DomUtil.getResultLong(cur, "USERID"); 954 if (userid != -1) 955 { 956 source = userid; 957 } 958 else 959 { 960 groupid = DomUtil.getResultLong(cur, "GROUPID"); 961 source = groupid; 962 } 963 964 // Allow Modify only if the user has the authority 965 if (core.rightModify(elementid, module)) { 966 967 iroot = core.getDoc().createElement("UPDATE"); 968 Element set = core.getDoc().createElement("SET"); 969 iroot.appendChild(set); 970 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTVIEW", rightsView.rightview)); 971 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTCREATE", rightsView.rightcreate)); 972 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTMODIFY", rightsView.rightmodify)); 973 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTDELETE", rightsView.rightdelete)); 974 set.appendChild(DomUtil.CreateNode(core.getDoc(), "RIGHTQM", rightsView.rightqm)); 975 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT1", rightsView.special1)); 976 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT2", rightsView.special2)); 977 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT3", rightsView.special3)); 978 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT4", rightsView.special4)); 979 set.appendChild(DomUtil.CreateNode(core.getDoc(), "SPECIALRIGHT5", rightsView.special5)); 980 981 wheres = core.getDoc().createElement("WHERE"); 982 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "MODULE", module)); 983 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "ELEMENT", rightsView.elementid)); 984 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "SOURCE", source)); 985 iroot.appendChild(wheres); 986 rightsView.updateEntryWhereClause(pool, iroot); 987 988 } 989 // Reload cached authorities 990 core.reloadRights(); 991 if (conf != null) 992 conf.clearRightCache(core); 993 return (eventer.success()); 994 } 995 return eventer.nosuccess(Eventer.ENTRY_NOT_EXIST, String.valueOf(rightsView.id)); 996 997 } catch (Exception e) { 998 eventer.fatalError(e.getMessage()); 999 e.printStackTrace(); 1000 } 1001 return null; 1002 } 1003 1004 1005 /** 1006 * Copies the authorities in the array to the childs of the group. 1007 * @param groupid the parent group to which childs the authorities should be copied 1008 * @param authorities the String[] of authorities 1009 */ 1010 private void copyAuthoritiesToChilds (long groupid, String[] authorities) 1011 { 1012 //Search for all childs of the group 1013 ArrayList<Long> groups = getGroupChilds(groupid); 1014 1015 for (int j = 0; groups != null && j < groups.size(); j++) 1016 { 1017 // create the authorities for all childgroups 1018 for (int i = 0; i < authorities.length; i++) 1019 this.createFunctionAuthority(((Long)groups.get(j)).longValue(), authorities[i], -1, groupid); 1020 } 1021 } 1022 1023 1024 /** 1025 * Copies the given authorities to all childs of the group. 1026 * @param groupid the groupid to which childs the authority is 1027 * @param elementid 1028 * @param rightview 1029 * @param rightcreate 1030 * @param rightmodify 1031 * @param rightdelete 1032 * @param rightqm 1033 * @param special1 1034 * @param special2 1035 * @param special3 1036 * @param special4 1037 * @param special5 1038 * @param module 1039 */ 1040 private void copyAuthorityToChilds (long groupid, long elementid, boolean rightview, boolean rightcreate, boolean rightmodify, boolean rightdelete, boolean rightqm, boolean special1, boolean special2, boolean special3, boolean special4, boolean special5, String module) 1041 { 1042 1043 //groups 1044 ArrayList<Long> groups = getGroupChilds(groupid); 1045 //ArrayList users = null; 1046 for (int j = 0; groups != null && j < groups.size(); j++) 1047 { 1048 this.createEntry(elementid, 1049 -1, 1050 ((Long)groups.get(j)).longValue(), 1051 rightview, 1052 rightcreate, 1053 rightmodify, 1054 rightdelete, 1055 rightqm, 1056 special1, 1057 special2, 1058 special3, 1059 special4, 1060 special5, 1061 module, 1062 groupid, 1063 false); 1064 } 1065 } 1066 1067 /** 1068 * Copies all function authorites of the group to all the groups in the Arraylist. 1069 * @param group the group where to copy the authorities from 1070 * @param childgroups the childgroups in an ArrayList 1071 */ 1072 protected void copyFunctionAuthoritiesToGroups (long group, ArrayList<Long> childgroups) 1073 { 1074 // Get the authorities of the group 1075 Element iroot = core.getDoc().createElement("SELECT"); 1076 Element wheres = core.getDoc().createElement("WHERE"); 1077 iroot.appendChild(wheres); 1078 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", group)); 1079 1080 Element results = authorityView.selectEntriesWhereClause(pool, iroot); 1081 1081 for (Element cur : new ChildElementAdapter(results)) 1082 1082 { 1083 for (int j = 0; childgroups != null && j < childgroups.size(); j++)1084 this.createFunctionAuthority(((Long)childgroups.get(j)).longValue(), DomUtil.getResultString(cur, "AUTHORITY"), -1, DomUtil.getResultLong(cur, "SOURCE"));1085 }1086 }1087 1088 /**1089 * Deletes all authoritiesy of an user.1090 * @param userid1091 */1092 protected void deleteUser (long userid)1093 {1094 Element iroot = core.getDoc().createElement("DELETE");1095 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", userid));1096 authorityView.deleteEntry(pool, iroot);1097 }1098 1099 /**1100 * Copies the authorities of groups to the childgroups of each group.1101 * @param al ArrayList of groups1102 */1103 private void copyAuthoritiesToChildGroups(ArrayList<Long> al)1104 {1105 for (int i = 0; i < al.size(); i++)1106 {1107 // getting child groups1108 ArrayList<Long> groups = getGroupChilds(((Long)al.get(i)).longValue());1109 if (groups != null && groups.size() > 0)1110 {1111 // copy the authorities to the childgroups1112 this.copyFunctionAuthoritiesToGroups(((Long)al.get(i)).longValue(), groups);1113 this.copyElementAuthoritiesToGroups(((Long)al.get(i)).longValue(), groups);1114 }1115 }1116 }1117 1118 1083 for (int j = 0; childgroups != null && j < childgroups.size(); j++) 1084 this.createFunctionAuthority(((Long)childgroups.get(j)).longValue(), DomUtil.getResultString(cur, "AUTHORITY"), -1, DomUtil.getResultLong(cur, "SOURCE")); 1085 } 1086 } 1087 1088 /** 1089 * Deletes all authoritiesy of an user. 1090 * @param userid 1091 */ 1092 protected void deleteUser (long userid) 1093 { 1094 Element iroot = core.getDoc().createElement("DELETE"); 1095 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", userid)); 1096 authorityView.deleteEntry(pool, iroot); 1097 } 1098 1099 /** 1100 * Copies the authorities of groups to the childgroups of each group. 1101 * @param al ArrayList of groups 1102 */ 1103 private void copyAuthoritiesToChildGroups(ArrayList<Long> al) 1104 { 1105 for (int i = 0; i < al.size(); i++) 1106 { 1107 // getting child groups 1108 ArrayList<Long> groups = getGroupChilds(((Long)al.get(i)).longValue()); 1109 if (groups != null && groups.size() > 0) 1110 { 1111 // copy the authorities to the childgroups 1112 this.copyFunctionAuthoritiesToGroups(((Long)al.get(i)).longValue(), groups); 1113 this.copyElementAuthoritiesToGroups(((Long)al.get(i)).longValue(), groups); 1114 } 1115 } 1116 } 1117 1118 1119 1119 /** 1120 1120 * Copies the authorities of one element to another element … … 1126 1126 { 1127 1127 ElementAuthorityView eauth = new ElementAuthorityView(core); 1128 1128 1129 1129 Element iroot = core.getDoc().createElement("COMBINEDSTATEMENT"); 1130 1131 Element select = core.getDoc().createElement("SELECT");1132 iroot.appendChild(select);1130 1131 Element select = core.getDoc().createElement("SELECT"); 1132 iroot.appendChild(select); 1133 1133 Element wheres = core.getDoc().createElement("WHERE"); 1134 select.appendChild(wheres);1135 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "element", fromelement));1136 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module));1137 1138 Element create = core.getDoc().createElement("CREATE");1139 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableidrowname", "id"));1140 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableviewclass", "corinis.modules.data.ElementAuthorityView"));1141 iroot.appendChild(create);1142 1143 Element fields = core.getDoc().createElement("FIELDS");1144 create.appendChild(fields);1145 1146 Element field = core.getDoc().createElement("FIELD");1147 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightview"));1148 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightview"));1149 fields.appendChild(field);1150 1151 field = core.getDoc().createElement("FIELD");1152 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "userid"));1153 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid"));1154 fields.appendChild(field);1155 1156 field = core.getDoc().createElement("FIELD");1157 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "groupid"));1158 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid"));1159 fields.appendChild(field);1160 1161 field = core.getDoc().createElement("FIELD");1162 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightcreate"));1163 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightcreate"));1164 fields.appendChild(field);1165 1166 field = core.getDoc().createElement("FIELD");1167 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightmodify"));1168 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightmodify"));1169 fields.appendChild(field);1170 1171 field = core.getDoc().createElement("FIELD");1172 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightdelete"));1173 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightdelete"));1174 fields.appendChild(field);1175 1176 field = core.getDoc().createElement("FIELD");1177 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightqm"));1178 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightqm"));1179 fields.appendChild(field);1180 1181 field = core.getDoc().createElement("FIELD");1182 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright1"));1183 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright1"));1184 fields.appendChild(field);1185 1186 field = core.getDoc().createElement("FIELD");1187 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright2"));1188 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright2"));1189 fields.appendChild(field);1190 1191 field = core.getDoc().createElement("FIELD");1192 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright3"));1193 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright3"));1194 fields.appendChild(field);1195 1196 field = core.getDoc().createElement("FIELD");1197 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright4"));1198 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright4"));1199 fields.appendChild(field);1200 1201 field = core.getDoc().createElement("FIELD");1202 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright5"));1203 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright5"));1204 fields.appendChild(field);1205 1206 field = core.getDoc().createElement("FIELD");1207 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "module"));1208 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "module"));1209 fields.appendChild(field);1210 1211 field = core.getDoc().createElement("FIELD");1212 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "source"));1213 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "source"));1214 fields.appendChild(field);1215 1216 Element fixed = core.getDoc().createElement("FIXEDVALUES");1217 create.appendChild(fixed);1218 1219 field = core.getDoc().createElement("FIELD");1220 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", toelement));1221 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "element"));1222 fixed.appendChild(field);1223 1224 eauth.combinedStatement(pool, iroot);1225 1226 // Clear the right Cache1227 conf.clearRightCache(core);1228 } 1229 1134 select.appendChild(wheres); 1135 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "element", fromelement)); 1136 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module)); 1137 1138 Element create = core.getDoc().createElement("CREATE"); 1139 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableidrowname", "id")); 1140 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableviewclass", "corinis.modules.data.ElementAuthorityView")); 1141 iroot.appendChild(create); 1142 1143 Element fields = core.getDoc().createElement("FIELDS"); 1144 create.appendChild(fields); 1145 1146 Element field = core.getDoc().createElement("FIELD"); 1147 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightview")); 1148 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightview")); 1149 fields.appendChild(field); 1150 1151 field = core.getDoc().createElement("FIELD"); 1152 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "userid")); 1153 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid")); 1154 fields.appendChild(field); 1155 1156 field = core.getDoc().createElement("FIELD"); 1157 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "groupid")); 1158 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid")); 1159 fields.appendChild(field); 1160 1161 field = core.getDoc().createElement("FIELD"); 1162 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightcreate")); 1163 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightcreate")); 1164 fields.appendChild(field); 1165 1166 field = core.getDoc().createElement("FIELD"); 1167 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightmodify")); 1168 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightmodify")); 1169 fields.appendChild(field); 1170 1171 field = core.getDoc().createElement("FIELD"); 1172 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightdelete")); 1173 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightdelete")); 1174 fields.appendChild(field); 1175 1176 field = core.getDoc().createElement("FIELD"); 1177 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightqm")); 1178 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightqm")); 1179 fields.appendChild(field); 1180 1181 field = core.getDoc().createElement("FIELD"); 1182 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright1")); 1183 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright1")); 1184 fields.appendChild(field); 1185 1186 field = core.getDoc().createElement("FIELD"); 1187 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright2")); 1188 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright2")); 1189 fields.appendChild(field); 1190 1191 field = core.getDoc().createElement("FIELD"); 1192 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright3")); 1193 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright3")); 1194 fields.appendChild(field); 1195 1196 field = core.getDoc().createElement("FIELD"); 1197 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright4")); 1198 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright4")); 1199 fields.appendChild(field); 1200 1201 field = core.getDoc().createElement("FIELD"); 1202 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright5")); 1203 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright5")); 1204 fields.appendChild(field); 1205 1206 field = core.getDoc().createElement("FIELD"); 1207 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "module")); 1208 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "module")); 1209 fields.appendChild(field); 1210 1211 field = core.getDoc().createElement("FIELD"); 1212 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "source")); 1213 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "source")); 1214 fields.appendChild(field); 1215 1216 Element fixed = core.getDoc().createElement("FIXEDVALUES"); 1217 create.appendChild(fixed); 1218 1219 field = core.getDoc().createElement("FIELD"); 1220 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", toelement)); 1221 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "element")); 1222 fixed.appendChild(field); 1223 1224 eauth.combinedStatement(pool, iroot); 1225 1226 // Clear the right Cache 1227 conf.clearRightCache(core); 1228 } 1229 1230 1230 /** 1231 1231 * Copies the authorities of the group to the groups in the arraylist. … … 1265 1265 } 1266 1266 1267 /**1268 * Deletes all rights in for the specified element.1267 /** 1268 * Deletes all rights in for the specified element. 1269 1269 * @param elementid the elementid 1270 1270 * @param module the module 1271 */1272 public void deleteByElement(long elementid, String module) {1273 1274 Element iroot = core.getDoc().createElement("DELETE");1275 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "element", String.valueOf(elementid)));1276 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module));1277 rightsView.deleteEntry(pool, iroot);1278 }1271 */ 1272 public void deleteByElement(long elementid, String module) { 1273 1274 Element iroot = core.getDoc().createElement("DELETE"); 1275 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "element", String.valueOf(elementid))); 1276 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "module", module)); 1277 rightsView.deleteEntry(pool, iroot); 1278 } 1279 1279 1280 1280 /** … … 1287 1287 { 1288 1288 ElementAuthorityView eauth = new ElementAuthorityView(core); 1289 1289 1290 1290 Element iroot = core.getDoc().createElement("COMBINEDSTATEMENT"); 1291 1292 Element select = core.getDoc().createElement("SELECT");1293 iroot.appendChild(select);1291 1292 Element select = core.getDoc().createElement("SELECT"); 1293 iroot.appendChild(select); 1294 1294 Element wheres = core.getDoc().createElement("WHERE"); 1295 select.appendChild(wheres);1296 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", parent));1297 1298 Element create = core.getDoc().createElement("CREATE");1299 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableidrowname", "id"));1300 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableviewclass", "corinis.modules.data.ElementAuthorityView"));1301 iroot.appendChild(create);1302 1303 Element fields = core.getDoc().createElement("FIELDS");1304 create.appendChild(fields);1305 1306 Element field = core.getDoc().createElement("FIELD");1307 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "element"));1308 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "element"));1309 fields.appendChild(field);1310 1311 field = core.getDoc().createElement("FIELD");1312 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightview"));1313 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightview"));1314 fields.appendChild(field);1315 1316 field = core.getDoc().createElement("FIELD");1317 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightcreate"));1318 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightcreate"));1319 fields.appendChild(field);1320 1321 field = core.getDoc().createElement("FIELD");1322 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightmodify"));1323 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightmodify"));1324 fields.appendChild(field);1325 1326 field = core.getDoc().createElement("FIELD");1327 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightdelete"));1328 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightdelete"));1329 fields.appendChild(field);1330 1331 field = core.getDoc().createElement("FIELD");1332 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightqm"));1333 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightqm"));1334 fields.appendChild(field);1335 1336 field = core.getDoc().createElement("FIELD");1337 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright1"));1338 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright1"));1339 fields.appendChild(field);1340 1341 field = core.getDoc().createElement("FIELD");1342 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright2"));1343 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright2"));1344 fields.appendChild(field);1345 1346 field = core.getDoc().createElement("FIELD");1347 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright3"));1348 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright3"));1349 fields.appendChild(field);1350 1351 field = core.getDoc().createElement("FIELD");1352 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright4"));1353 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright4"));1354 fields.appendChild(field);1355 1356 field = core.getDoc().createElement("FIELD");1357 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright5"));1358 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright5"));1359 fields.appendChild(field);1360 1361 field = core.getDoc().createElement("FIELD");1362 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "module"));1363 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "module"));1364 fields.appendChild(field);1365 1366 field = core.getDoc().createElement("FIELD");1367 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "source"));1368 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "source"));1369 fields.appendChild(field);1370 1371 Element fixed = core.getDoc().createElement("FIXEDVALUES");1372 create.appendChild(fixed);1373 1374 if (childisuser)1375 {1376 field = core.getDoc().createElement("FIELD");1377 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", child));1378 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid"));1379 fixed.appendChild(field);1380 1381 field = core.getDoc().createElement("FIELD");1382 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", -1));1383 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid"));1384 fixed.appendChild(field);1385 }1386 else1387 {1388 field = core.getDoc().createElement("FIELD");1389 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", -1));1390 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid"));1391 fixed.appendChild(field);1392 1393 field = core.getDoc().createElement("FIELD");1394 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", child));1395 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid"));1396 fixed.appendChild(field);1397 }1398 1399 eauth.combinedStatement(pool, iroot);1400 1401 // Clear Rightcache1402 conf.clearRightCache(core);1403 } 1404 1405 /** 1406 * Copies all element authorites of the group to the child.1407 * @param parent the parentgroup to copy the authorities from1295 select.appendChild(wheres); 1296 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", parent)); 1297 1298 Element create = core.getDoc().createElement("CREATE"); 1299 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableidrowname", "id")); 1300 create.appendChild(DomUtil.CreateNode(core.getDoc(), "tableviewclass", "corinis.modules.data.ElementAuthorityView")); 1301 iroot.appendChild(create); 1302 1303 Element fields = core.getDoc().createElement("FIELDS"); 1304 create.appendChild(fields); 1305 1306 Element field = core.getDoc().createElement("FIELD"); 1307 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "element")); 1308 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "element")); 1309 fields.appendChild(field); 1310 1311 field = core.getDoc().createElement("FIELD"); 1312 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightview")); 1313 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightview")); 1314 fields.appendChild(field); 1315 1316 field = core.getDoc().createElement("FIELD"); 1317 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightcreate")); 1318 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightcreate")); 1319 fields.appendChild(field); 1320 1321 field = core.getDoc().createElement("FIELD"); 1322 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightmodify")); 1323 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightmodify")); 1324 fields.appendChild(field); 1325 1326 field = core.getDoc().createElement("FIELD"); 1327 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightdelete")); 1328 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightdelete")); 1329 fields.appendChild(field); 1330 1331 field = core.getDoc().createElement("FIELD"); 1332 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "rightqm")); 1333 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "rightqm")); 1334 fields.appendChild(field); 1335 1336 field = core.getDoc().createElement("FIELD"); 1337 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright1")); 1338 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright1")); 1339 fields.appendChild(field); 1340 1341 field = core.getDoc().createElement("FIELD"); 1342 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright2")); 1343 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright2")); 1344 fields.appendChild(field); 1345 1346 field = core.getDoc().createElement("FIELD"); 1347 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright3")); 1348 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright3")); 1349 fields.appendChild(field); 1350 1351 field = core.getDoc().createElement("FIELD"); 1352 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright4")); 1353 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright4")); 1354 fields.appendChild(field); 1355 1356 field = core.getDoc().createElement("FIELD"); 1357 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "specialright5")); 1358 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "specialright5")); 1359 fields.appendChild(field); 1360 1361 field = core.getDoc().createElement("FIELD"); 1362 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "module")); 1363 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "module")); 1364 fields.appendChild(field); 1365 1366 field = core.getDoc().createElement("FIELD"); 1367 field.appendChild(DomUtil.CreateNode(core.getDoc(), "selectname", "source")); 1368 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "source")); 1369 fields.appendChild(field); 1370 1371 Element fixed = core.getDoc().createElement("FIXEDVALUES"); 1372 create.appendChild(fixed); 1373 1374 if (childisuser) 1375 { 1376 field = core.getDoc().createElement("FIELD"); 1377 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", child)); 1378 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid")); 1379 fixed.appendChild(field); 1380 1381 field = core.getDoc().createElement("FIELD"); 1382 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", -1)); 1383 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid")); 1384 fixed.appendChild(field); 1385 } 1386 else 1387 { 1388 field = core.getDoc().createElement("FIELD"); 1389 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", -1)); 1390 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "userid")); 1391 fixed.appendChild(field); 1392 1393 field = core.getDoc().createElement("FIELD"); 1394 field.appendChild(DomUtil.CreateNode(core.getDoc(), "value", child)); 1395 field.appendChild(DomUtil.CreateNode(core.getDoc(), "tablerowname", "groupid")); 1396 fixed.appendChild(field); 1397 } 1398 1399 eauth.combinedStatement(pool, iroot); 1400 1401 // Clear Rightcache 1402 conf.clearRightCache(core); 1403 } 1404 1405 /** 1406 * Copies all element authorites of the group to the child. 1407 * @param parent the parentgroup to copy the authorities from 1408 1408 * @param child the childid 1409 1409 * @param childisuser true if the child is a user, false if its a group 1410 */1411 protected void copyFunctionAuthoritiesToChild (long parent, long child, boolean childisuser)1412 {1413 Element iroot = core.getDoc().createElement("SELECT");1414 Element wheres = core.getDoc().createElement("WHERE");1415 iroot.appendChild(wheres);1416 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", parent));1417 1418 Element results = authorityView.selectEntriesWhereClause(pool, iroot);1410 */ 1411 protected void copyFunctionAuthoritiesToChild (long parent, long child, boolean childisuser) 1412 { 1413 Element iroot = core.getDoc().createElement("SELECT"); 1414 Element wheres = core.getDoc().createElement("WHERE"); 1415 iroot.appendChild(wheres); 1416 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", parent)); 1417 1418 Element results = authorityView.selectEntriesWhereClause(pool, iroot); 1419 1419 for (Element cur : new ChildElementAdapter(results)) 1420 1420 { 1421 if (childisuser)1422 this.createFunctionAuthority(-1, DomUtil.getResultString(cur, "AUTHORITY"), child, DomUtil.getResultLong(cur, "SOURCE"));1423 else1424 this.createFunctionAuthority(child, DomUtil.getResultString(cur, "AUTHORITY"), -1, DomUtil.getResultLong(cur, "SOURCE"));1425 }1426 }1427 1428 1421 if (childisuser) 1422 this.createFunctionAuthority(-1, DomUtil.getResultString(cur, "AUTHORITY"), child, DomUtil.getResultLong(cur, "SOURCE")); 1423 else 1424 this.createFunctionAuthority(child, DomUtil.getResultString(cur, "AUTHORITY"), -1, DomUtil.getResultLong(cur, "SOURCE")); 1425 } 1426 } 1427 1428 1429 1429 /** 1430 1430 * Sets up the AuthorityManager … … 1433 1433 */ 1434 1434 public void setUpModule(dbConnectionBroker pool, Writer wr) throws Exception { 1435 1436 this.pool = pool;1437 // General module setup things, if available1438 super.setUpModule(pool, wr);1439 1440 AuthorityUserGroupView aug = new AuthorityUserGroupView(core);1441 /****************/1442 /*Repair Section*/1443 /****************/1444 1445 // Update null values in the database to -11446 Element iroot = core.getDoc().createElement("UPDATE");1447 Element set = core.getDoc().createElement("SET");1448 iroot.appendChild(set);1449 set.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", "-1"));1450 Element wheres = core.getDoc().createElement("WHERE");1451 iroot.appendChild(wheres);1452 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", "null"));1453 authorityView.updateEntryWhereClause(pool, iroot);1454 rightsView.updateEntryWhereClause(pool, iroot);1455 1456 iroot = core.getDoc().createElement("UPDATE");1457 set = core.getDoc().createElement("SET");1458 iroot.appendChild(set);1459 set.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", "-1"));1460 wheres = core.getDoc().createElement("WHERE");1461 iroot.appendChild(wheres);1462 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", "null"));1463 authorityView.updateEntryWhereClause(pool, iroot);1464 rightsView.updateEntryWhereClause(pool, iroot);1465 1466 // Delete all derived rights1467 iroot = core.getDoc().createElement("DELETE");1468 Element not = core.getDoc().createElement("NOT");1469 iroot.appendChild(not);1470 not.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "groupid"));1471 Element gt = core.getDoc().createElement("GT");1472 iroot.appendChild(gt);1473 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0));1474 1475 authorityView.deleteEntry(pool, iroot);1476 rightsView.deleteEntry(pool, iroot);1477 1478 // check consistence1479 // this is source, groupid in Element/FunctionAuthorityView1480 // and groupid/parent in AuthorityuserGroupView1481 // -> check if these groups exist in AuthorityGroup - if not - delete it1482 1483 // Getting all authority groups - in a hashmap1484 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core);1485 1486 iroot = core.getDoc().createElement("SELECT");1487 Element fields = core.getDoc().createElement("FIELDS");1488 iroot.appendChild(fields);1489 fields.appendChild(core.getDoc().createElement("ID"));1490 Element results = authorityGroupView.selectEntriesWhereClause(pool, iroot);1491 1492 HashMap<String, String> groups = new HashMap<String, String>();1493 1494 for (Element cur : new ChildElementAdapter(results))1495 groups.put(DomUtil.getResultString(cur, "ID"), DomUtil.getResultString(cur, "ID"));1496 1497 // Adding all group to the ArrayList for which authorities (element or function) exist1498 ArrayList<String> groupsToCheck = new ArrayList<String>();1499 1500 iroot = core.getDoc().createElement("SELECT");1501 fields = core.getDoc().createElement("FIELDS");1502 iroot.appendChild(fields);1503 fields.appendChild(core.getDoc().createElement("GROUPID"));1504 wheres = core.getDoc().createElement("WHERE");1505 iroot.appendChild(wheres);1506 gt = core.getDoc().createElement("GT");1507 wheres.appendChild(gt);1508 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0));1509 results = this.rightsView.selectEntriesWhereClause(pool, iroot);1510 1511 for (Element cur : new ChildElementAdapter(results))1512 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID"));1513 1514 results = this.authorityView.selectEntriesWhereClause(pool, iroot);1515 1516 for (Element cur : new ChildElementAdapter(results))1517 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID"));1518 1519 for (int i = 0; i < groupsToCheck.size(); i++)1520 {1521 // delete entries if not in groups hashmap1522 // e.g if the is a groupid in authoritytable but this group does not exist - delete the entry1523 if (! groups.containsKey(groupsToCheck.get(i)))1524 {1525 iroot = core.getDoc().createElement("DELETE");1526 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", (String)groupsToCheck.get(i)));1527 rightsView.deleteEntry(pool, iroot);1528 authorityView.deleteEntry(pool, iroot);1529 }1530 }1531 1532 1533 // Now do the same for all groups to which a reference exists1534 // Meaning all authorities which are stated to be derived from a group which does not exist1535 // e.g. check the SOURCE row in DB instead of the GROUPID row as above1536 groupsToCheck = new ArrayList<String>();1537 1538 iroot = core.getDoc().createElement("SELECT");1539 fields = core.getDoc().createElement("FIELDS");1540 iroot.appendChild(fields);1541 fields.appendChild(core.getDoc().createElement("SOURCE"));1542 wheres = core.getDoc().createElement("WHERE");1543 iroot.appendChild(wheres);1544 gt = core.getDoc().createElement("GT");1545 wheres.appendChild(gt);1546 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "source", 0));1547 results = this.rightsView.selectEntriesWhereClause(pool, iroot);1548 1549 for (Element cur : new ChildElementAdapter(results))1550 groupsToCheck.add(DomUtil.getResultString(cur, "SOURCE"));1551 1552 results = this.authorityView.selectEntriesWhereClause(pool, iroot);1553 1554 for (Element cur : new ChildElementAdapter(results))1555 groupsToCheck.add(DomUtil.getResultString(cur, "SOURCE"));1556 1557 for (int i = 0; i < groupsToCheck.size(); i++)1558 {1559 // Delete entries if not in groups hashmap1560 if (! groups.containsKey(groupsToCheck.get(i)))1561 {1562 iroot = core.getDoc().createElement("DELETE");1563 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "source", (String)groupsToCheck.get(i)));1564 rightsView.deleteEntry(pool, iroot);1565 authorityView.deleteEntry(pool, iroot);1566 }1567 }1568 1569 // Check all AuthorityUserGroup entries for groups which don't exist1570 // same procedure as above1571 iroot = core.getDoc().createElement("SELECT");1572 fields = core.getDoc().createElement("FIELDS");1573 iroot.appendChild(fields);1574 fields.appendChild(core.getDoc().createElement("GROUPID"));1575 wheres = core.getDoc().createElement("WHERE");1576 iroot.appendChild(wheres);1577 gt = core.getDoc().createElement("GT");1578 wheres.appendChild(gt);1579 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0));1580 results = aug.selectEntriesWhereClause(pool, iroot);1581 1582 for (Element cur : new ChildElementAdapter(results))1583 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID"));1584 1585 iroot = core.getDoc().createElement("SELECT");1586 fields = core.getDoc().createElement("FIELDS");1587 iroot.appendChild(fields);1588 fields.appendChild(core.getDoc().createElement("PARENT"));1589 wheres = core.getDoc().createElement("WHERE");1590 iroot.appendChild(wheres);1591 gt = core.getDoc().createElement("GT");1592 wheres.appendChild(gt);1593 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", 0));1594 results = aug.selectEntriesWhereClause(pool, iroot);1595 1596 for (Element cur : new ChildElementAdapter(results))1597 groupsToCheck.add(DomUtil.getResultString(cur, "PARENT"));1598 1599 for (int i = 0; i < groupsToCheck.size(); i++)1600 {1601 // delete entries if not in groups hashmap1602 if (! groups.containsKey(groupsToCheck.get(i)))1603 {1604 iroot = core.getDoc().createElement("DELETE");1605 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", (String)groupsToCheck.get(i)));1606 aug.deleteEntry(pool, iroot);1607 1608 iroot = core.getDoc().createElement("DELETE");1609 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", (String)groupsToCheck.get(i)));1610 aug.deleteEntry(pool, iroot);1611 1612 }1613 }1614 1615 1616 /****************/1617 /* Recreate Section**/1618 /* We have deleted all derived authorities, now we have to recreate it**/1619 /**********************************************************************/1620 1621 1622 // Get all rootgroups1623 iroot = core.getDoc().createElement("SELECT");1624 fields = core.getDoc().createElement("FIELDS");1625 iroot.appendChild(fields);1626 fields.appendChild(core.getDoc().createElement("groupid"));1627 wheres = core.getDoc().createElement("WHERE");1628 iroot.appendChild(wheres);1629 gt = core.getDoc().createElement(("GT"));1630 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0));1631 wheres.appendChild(gt);1632 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", -1));1633 1634 results = aug.selectEntriesWhereClause(pool, iroot);1635 1636 ArrayList<Long> rootgroups = new ArrayList<Long>();1637 if (results == null)1638 return;1639 for (Element cur : new ChildElementAdapter(results))1640 rootgroups.add (DomUtil.getResultLong(cur, "GROUPID"));1641 1642 // getChildgroups + users1643 copyAuthoritiesToChildGroups(rootgroups);1644 1645 // Deleting double Authorities:1646 1647 // Function Authority1648 iroot = core.getDoc().createElement("SELECT");1649 Element order = core.getDoc().createElement("ORDER");1650 iroot.appendChild(order);1651 order.appendChild(core.getDoc().createElement("AUTHORITY"));1652 order.appendChild(core.getDoc().createElement("USERID"));1653 order.appendChild(core.getDoc().createElement("GROUPID"));1654 order.appendChild(core.getDoc().createElement("SOURCE"));1655 results = this.authorityView.selectEntriesWhereClause(pool, iroot);1656 1657 ArrayList<String> ids = new ArrayList<String>();1658 authorityView.authority = null;1659 for (Element cur : new ChildElementAdapter(results))1660 {1661 // first time - just fill it1662 if (authorityView.authority == null)1663 {1664 authorityView.authority = new String[1];1665 authorityView.authority[0] = DomUtil.getResultString(cur, "authority");1666 authorityView.userid = DomUtil.getResultLong(cur, "userid");1667 authorityView.groupid = DomUtil.getResultLong(cur, "groupid");1668 authorityView.source = DomUtil.getResultLong(cur, "source");1669 }1670 else1671 {1672 if ( ((DomUtil.getResultString(cur, "authority") != null && DomUtil.getResultString(cur, "authority").equals(authorityView.authority[0]) ||1673 DomUtil.getResultString(cur, "authority") == null && authorityView.authority[0] == null)) &&1674 DomUtil.getResultLong(cur, "userid") == authorityView.userid &&1675 DomUtil.getResultLong(cur, "groupid") == authorityView.groupid &&1676 DomUtil.getResultLong(cur, "source") == authorityView.source)1677 ids.add(DomUtil.getResultString(cur, "ID"));1678 else1679 {1680 authorityView.authority[0] = DomUtil.getResultString(cur, "authority");1681 authorityView.userid = DomUtil.getResultLong(cur, "userid");1682 authorityView.groupid = DomUtil.getResultLong(cur, "groupid");1683 authorityView.source = DomUtil.getResultLong(cur, "source");1684 }1685 }1686 }1687 // Deleting1688 for (int i = 0; i < ids.size(); i++)1689 {1690 iroot = core.getDoc().createElement("DELETE");1691 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", (String)ids.get(i)));1692 authorityView.deleteEntry(pool, iroot);1693 }1694 1695 1696 // Element Authority1697 iroot = core.getDoc().createElement("SELECT");1698 order = core.getDoc().createElement("ORDER");1699 iroot.appendChild(order);1700 order.appendChild(core.getDoc().createElement("ELEMENT"));1701 order.appendChild(core.getDoc().createElement("MODULE"));1702 order.appendChild(core.getDoc().createElement("RIGHTVIEW"));1703 order.appendChild(core.getDoc().createElement("RIGHTCREATE"));1704 order.appendChild(core.getDoc().createElement("RIGHTDELETE"));1705 order.appendChild(core.getDoc().createElement("RIGHTMODIFY"));1706 order.appendChild(core.getDoc().createElement("RIGHTQM"));1707 order.appendChild(core.getDoc().createElement("SPECIALRIGHT1"));1708 order.appendChild(core.getDoc().createElement("SPECIALRIGHT2"));1709 order.appendChild(core.getDoc().createElement("SPECIALRIGHT3"));1710 order.appendChild(core.getDoc().createElement("SPECIALRIGHT4"));1711 order.appendChild(core.getDoc().createElement("SPECIALRIGHT5"));1712 order.appendChild(core.getDoc().createElement("USERID"));1713 order.appendChild(core.getDoc().createElement("GROUPID"));1714 order.appendChild(core.getDoc().createElement("SOURCE"));1715 results = this.rightsView.selectEntriesWhereClause(pool, iroot);1716 long userid = -2;1717 long groupid = -2;1718 ids = new ArrayList<String>();1719 for (Element cur : new ChildElementAdapter(results))1720 {1721 // first time - just fill it1722 if (userid == -2 && groupid == -2)1723 {1724 rightsView.elementid = DomUtil.getResultLong(cur, "element");1725 rightsView.module = DomUtil.getResultString(cur, "module");1726 rightsView.rightview = DomUtil.getResultBool(cur, "rightview");1727 rightsView.rightcreate = DomUtil.getResultBool(cur, "rightcreate");1728 rightsView.rightdelete = DomUtil.getResultBool(cur, "rightdelete");1729 rightsView.rightmodify = DomUtil.getResultBool(cur, "rightmodify");1730 rightsView.rightqm = DomUtil.getResultBool(cur, "rightqm");1731 rightsView.special1 = DomUtil.getResultBool(cur, "specialright1");1732 rightsView.special2 = DomUtil.getResultBool(cur, "specialright2");1733 rightsView.special3 = DomUtil.getResultBool(cur, "specialright3");1734 rightsView.special4 = DomUtil.getResultBool(cur, "specialright4");1735 rightsView.special5 = DomUtil.getResultBool(cur, "specialright5");1736 rightsView.source = DomUtil.getResultLong(cur, "source");1737 groupid = DomUtil.getResultLong(cur, "groupid");1738 userid = DomUtil.getResultLong(cur, "userid");1739 }1740 else1741 {1742 if (1743 DomUtil.getResultLong(cur, "element") == rightsView.elementid &&1744 ((DomUtil.getResultString(cur, "module") != null && rightsView.module != null &&1745 DomUtil.getResultString(cur, "module").equals(rightsView.module)) ||1746 (DomUtil.getResultString(cur, "module") == null && rightsView.module == null ))&&1747 DomUtil.getResultBool(cur, "rightview") == rightsView.rightview &&1748 DomUtil.getResultBool(cur, "rightcreate") == rightsView.rightcreate &&1749 DomUtil.getResultBool(cur, "rightdelete") == rightsView.rightdelete &&1750 DomUtil.getResultBool(cur, "rightmodify") == rightsView.rightmodify &&1751 DomUtil.getResultBool(cur, "rightqm") == rightsView.rightqm &&1752 DomUtil.getResultBool(cur, "specialright1") == rightsView.special1 &&1753 DomUtil.getResultBool(cur, "specialright2") == rightsView.special2 &&1754 DomUtil.getResultBool(cur, "specialright3") == rightsView.special3 &&1755 DomUtil.getResultBool(cur, "specialright4") == rightsView.special4 &&1756 DomUtil.getResultBool(cur, "specialright5") == rightsView.special5 &&1757 DomUtil.getResultLong(cur, "groupid") == groupid &&1758 DomUtil.getResultLong(cur, "userid") == userid &&1759 DomUtil.getResultLong(cur, "source") == rightsView.source)1760 ids.add(DomUtil.getResultString(cur, "ID"));1761 else1762 {1763 rightsView.elementid = DomUtil.getResultLong(cur, "element");1764 rightsView.module = DomUtil.getResultString(cur, "module");1765 rightsView.rightview = DomUtil.getResultBool(cur, "rightview");1766 rightsView.rightcreate = DomUtil.getResultBool(cur, "rightcreate");1767 rightsView.rightdelete = DomUtil.getResultBool(cur, "rightdelete");1768 rightsView.rightmodify = DomUtil.getResultBool(cur, "rightmodify");1769 rightsView.rightqm = DomUtil.getResultBool(cur, "rightqm");1770 rightsView.special1 = DomUtil.getResultBool(cur, "specialright1");1771 rightsView.special2 = DomUtil.getResultBool(cur, "specialright2");1772 rightsView.special3 = DomUtil.getResultBool(cur, "specialright3");1773 rightsView.special4 = DomUtil.getResultBool(cur, "specialright4");1774 rightsView.special5 = DomUtil.getResultBool(cur, "specialright5");1775 rightsView.source = DomUtil.getResultLong(cur, "source");1776 groupid = DomUtil.getResultLong(cur, "groupid");1777 userid = DomUtil.getResultLong(cur, "userid");1778 }1779 }1780 }1781 // Deleting1782 for (int i = 0; i < ids.size(); i++)1783 {1784 iroot = core.getDoc().createElement("DELETE");1785 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", (String)ids.get(i)));1786 rightsView.deleteEntry(pool, iroot);1787 }1788 }1789 1435 1436 this.pool = pool; 1437 // General module setup things, if available 1438 super.setUpModule(pool, wr); 1439 1440 AuthorityUserGroupView aug = new AuthorityUserGroupView(core); 1441 /****************/ 1442 /*Repair Section*/ 1443 /****************/ 1444 1445 // Update null values in the database to -1 1446 Element iroot = core.getDoc().createElement("UPDATE"); 1447 Element set = core.getDoc().createElement("SET"); 1448 iroot.appendChild(set); 1449 set.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", "-1")); 1450 Element wheres = core.getDoc().createElement("WHERE"); 1451 iroot.appendChild(wheres); 1452 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "userid", "null")); 1453 authorityView.updateEntryWhereClause(pool, iroot); 1454 rightsView.updateEntryWhereClause(pool, iroot); 1455 1456 iroot = core.getDoc().createElement("UPDATE"); 1457 set = core.getDoc().createElement("SET"); 1458 iroot.appendChild(set); 1459 set.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", "-1")); 1460 wheres = core.getDoc().createElement("WHERE"); 1461 iroot.appendChild(wheres); 1462 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", "null")); 1463 authorityView.updateEntryWhereClause(pool, iroot); 1464 rightsView.updateEntryWhereClause(pool, iroot); 1465 1466 // Delete all derived rights 1467 iroot = core.getDoc().createElement("DELETE"); 1468 Element not = core.getDoc().createElement("NOT"); 1469 iroot.appendChild(not); 1470 not.appendChild(DomUtil.CreateNode(core.getDoc(), "source", "groupid")); 1471 Element gt = core.getDoc().createElement("GT"); 1472 iroot.appendChild(gt); 1473 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0)); 1474 1475 authorityView.deleteEntry(pool, iroot); 1476 rightsView.deleteEntry(pool, iroot); 1477 1478 // check consistence 1479 // this is source, groupid in Element/FunctionAuthorityView 1480 // and groupid/parent in AuthorityuserGroupView 1481 // -> check if these groups exist in AuthorityGroup - if not - delete it 1482 1483 // Getting all authority groups - in a hashmap 1484 AuthorityGroupView authorityGroupView = new AuthorityGroupView(core); 1485 1486 iroot = core.getDoc().createElement("SELECT"); 1487 Element fields = core.getDoc().createElement("FIELDS"); 1488 iroot.appendChild(fields); 1489 fields.appendChild(core.getDoc().createElement("ID")); 1490 Element results = authorityGroupView.selectEntriesWhereClause(pool, iroot); 1491 1492 HashMap<String, String> groups = new HashMap<String, String>(); 1493 1494 for (Element cur : new ChildElementAdapter(results)) 1495 groups.put(DomUtil.getResultString(cur, "ID"), DomUtil.getResultString(cur, "ID")); 1496 1497 // Adding all group to the ArrayList for which authorities (element or function) exist 1498 ArrayList<String> groupsToCheck = new ArrayList<String>(); 1499 1500 iroot = core.getDoc().createElement("SELECT"); 1501 fields = core.getDoc().createElement("FIELDS"); 1502 iroot.appendChild(fields); 1503 fields.appendChild(core.getDoc().createElement("GROUPID")); 1504 wheres = core.getDoc().createElement("WHERE"); 1505 iroot.appendChild(wheres); 1506 gt = core.getDoc().createElement("GT"); 1507 wheres.appendChild(gt); 1508 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0)); 1509 results = this.rightsView.selectEntriesWhereClause(pool, iroot); 1510 1511 for (Element cur : new ChildElementAdapter(results)) 1512 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID")); 1513 1514 results = this.authorityView.selectEntriesWhereClause(pool, iroot); 1515 1516 for (Element cur : new ChildElementAdapter(results)) 1517 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID")); 1518 1519 for (int i = 0; i < groupsToCheck.size(); i++) 1520 { 1521 // delete entries if not in groups hashmap 1522 // e.g if the is a groupid in authoritytable but this group does not exist - delete the entry 1523 if (! groups.containsKey(groupsToCheck.get(i))) 1524 { 1525 iroot = core.getDoc().createElement("DELETE"); 1526 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", (String)groupsToCheck.get(i))); 1527 rightsView.deleteEntry(pool, iroot); 1528 authorityView.deleteEntry(pool, iroot); 1529 } 1530 } 1531 1532 1533 // Now do the same for all groups to which a reference exists 1534 // Meaning all authorities which are stated to be derived from a group which does not exist 1535 // e.g. check the SOURCE row in DB instead of the GROUPID row as above 1536 groupsToCheck = new ArrayList<String>(); 1537 1538 iroot = core.getDoc().createElement("SELECT"); 1539 fields = core.getDoc().createElement("FIELDS"); 1540 iroot.appendChild(fields); 1541 fields.appendChild(core.getDoc().createElement("SOURCE")); 1542 wheres = core.getDoc().createElement("WHERE"); 1543 iroot.appendChild(wheres); 1544 gt = core.getDoc().createElement("GT"); 1545 wheres.appendChild(gt); 1546 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "source", 0)); 1547 results = this.rightsView.selectEntriesWhereClause(pool, iroot); 1548 1549 for (Element cur : new ChildElementAdapter(results)) 1550 groupsToCheck.add(DomUtil.getResultString(cur, "SOURCE")); 1551 1552 results = this.authorityView.selectEntriesWhereClause(pool, iroot); 1553 1554 for (Element cur : new ChildElementAdapter(results)) 1555 groupsToCheck.add(DomUtil.getResultString(cur, "SOURCE")); 1556 1557 for (int i = 0; i < groupsToCheck.size(); i++) 1558 { 1559 // Delete entries if not in groups hashmap 1560 if (! groups.containsKey(groupsToCheck.get(i))) 1561 { 1562 iroot = core.getDoc().createElement("DELETE"); 1563 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "source", (String)groupsToCheck.get(i))); 1564 rightsView.deleteEntry(pool, iroot); 1565 authorityView.deleteEntry(pool, iroot); 1566 } 1567 } 1568 1569 // Check all AuthorityUserGroup entries for groups which don't exist 1570 // same procedure as above 1571 iroot = core.getDoc().createElement("SELECT"); 1572 fields = core.getDoc().createElement("FIELDS"); 1573 iroot.appendChild(fields); 1574 fields.appendChild(core.getDoc().createElement("GROUPID")); 1575 wheres = core.getDoc().createElement("WHERE"); 1576 iroot.appendChild(wheres); 1577 gt = core.getDoc().createElement("GT"); 1578 wheres.appendChild(gt); 1579 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0)); 1580 results = aug.selectEntriesWhereClause(pool, iroot); 1581 1582 for (Element cur : new ChildElementAdapter(results)) 1583 groupsToCheck.add(DomUtil.getResultString(cur, "GROUPID")); 1584 1585 iroot = core.getDoc().createElement("SELECT"); 1586 fields = core.getDoc().createElement("FIELDS"); 1587 iroot.appendChild(fields); 1588 fields.appendChild(core.getDoc().createElement("PARENT")); 1589 wheres = core.getDoc().createElement("WHERE"); 1590 iroot.appendChild(wheres); 1591 gt = core.getDoc().createElement("GT"); 1592 wheres.appendChild(gt); 1593 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", 0)); 1594 results = aug.selectEntriesWhereClause(pool, iroot); 1595 1596 for (Element cur : new ChildElementAdapter(results)) 1597 groupsToCheck.add(DomUtil.getResultString(cur, "PARENT")); 1598 1599 for (int i = 0; i < groupsToCheck.size(); i++) 1600 { 1601 // delete entries if not in groups hashmap 1602 if (! groups.containsKey(groupsToCheck.get(i))) 1603 { 1604 iroot = core.getDoc().createElement("DELETE"); 1605 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", (String)groupsToCheck.get(i))); 1606 aug.deleteEntry(pool, iroot); 1607 1608 iroot = core.getDoc().createElement("DELETE"); 1609 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", (String)groupsToCheck.get(i))); 1610 aug.deleteEntry(pool, iroot); 1611 1612 } 1613 } 1614 1615 1616 /****************/ 1617 /* Recreate Section**/ 1618 /* We have deleted all derived authorities, now we have to recreate it**/ 1619 /**********************************************************************/ 1620 1621 1622 // Get all rootgroups 1623 iroot = core.getDoc().createElement("SELECT"); 1624 fields = core.getDoc().createElement("FIELDS"); 1625 iroot.appendChild(fields); 1626 fields.appendChild(core.getDoc().createElement("groupid")); 1627 wheres = core.getDoc().createElement("WHERE"); 1628 iroot.appendChild(wheres); 1629 gt = core.getDoc().createElement(("GT")); 1630 gt.appendChild(DomUtil.CreateNode(core.getDoc(), "groupid", 0)); 1631 wheres.appendChild(gt); 1632 wheres.appendChild(DomUtil.CreateNode(core.getDoc(), "parent", -1)); 1633 1634 results = aug.selectEntriesWhereClause(pool, iroot); 1635 1636 ArrayList<Long> rootgroups = new ArrayList<Long>(); 1637 if (results == null) 1638 return; 1639 for (Element cur : new ChildElementAdapter(results)) 1640 rootgroups.add (DomUtil.getResultLong(cur, "GROUPID")); 1641 1642 // getChildgroups + users 1643 copyAuthoritiesToChildGroups(rootgroups); 1644 1645 // Deleting double Authorities: 1646 1647 // Function Authority 1648 iroot = core.getDoc().createElement("SELECT"); 1649 Element order = core.getDoc().createElement("ORDER"); 1650 iroot.appendChild(order); 1651 order.appendChild(core.getDoc().createElement("AUTHORITY")); 1652 order.appendChild(core.getDoc().createElement("USERID")); 1653 order.appendChild(core.getDoc().createElement("GROUPID")); 1654 order.appendChild(core.getDoc().createElement("SOURCE")); 1655 results = this.authorityView.selectEntriesWhereClause(pool, iroot); 1656 1657 ArrayList<String> ids = new ArrayList<String>(); 1658 authorityView.authority = null; 1659 for (Element cur : new ChildElementAdapter(results)) 1660 { 1661 // first time - just fill it 1662 if (authorityView.authority == null) 1663 { 1664 authorityView.authority = new String[1]; 1665 authorityView.authority[0] = DomUtil.getResultString(cur, "authority"); 1666 authorityView.userid = DomUtil.getResultLong(cur, "userid"); 1667 authorityView.groupid = DomUtil.getResultLong(cur, "groupid"); 1668 authorityView.source = DomUtil.getResultLong(cur, "source"); 1669 } 1670 else 1671 { 1672 if ( ((DomUtil.getResultString(cur, "authority") != null && DomUtil.getResultString(cur, "authority").equals(authorityView.authority[0]) || 1673 DomUtil.getResultString(cur, "authority") == null && authorityView.authority[0] == null)) && 1674 DomUtil.getResultLong(cur, "userid") == authorityView.userid && 1675 DomUtil.getResultLong(cur, "groupid") == authorityView.groupid && 1676 DomUtil.getResultLong(cur, "source") == authorityView.source) 1677 ids.add(DomUtil.getResultString(cur, "ID")); 1678 else 1679 { 1680 authorityView.authority[0] = DomUtil.getResultString(cur, "authority"); 1681 authorityView.userid = DomUtil.getResultLong(cur, "userid"); 1682 authorityView.groupid = DomUtil.getResultLong(cur, "groupid"); 1683 authorityView.source = DomUtil.getResultLong(cur, "source"); 1684 } 1685 } 1686 } 1687 // Deleting 1688 for (int i = 0; i < ids.size(); i++) 1689 { 1690 iroot = core.getDoc().createElement("DELETE"); 1691 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", (String)ids.get(i))); 1692 authorityView.deleteEntry(pool, iroot); 1693 } 1694 1695 1696 // Element Authority 1697 iroot = core.getDoc().createElement("SELECT"); 1698 order = core.getDoc().createElement("ORDER"); 1699 iroot.appendChild(order); 1700 order.appendChild(core.getDoc().createElement("ELEMENT")); 1701 order.appendChild(core.getDoc().createElement("MODULE")); 1702 order.appendChild(core.getDoc().createElement("RIGHTVIEW")); 1703 order.appendChild(core.getDoc().createElement("RIGHTCREATE")); 1704 order.appendChild(core.getDoc().createElement("RIGHTDELETE")); 1705 order.appendChild(core.getDoc().createElement("RIGHTMODIFY")); 1706 order.appendChild(core.getDoc().createElement("RIGHTQM")); 1707 order.appendChild(core.getDoc().createElement("SPECIALRIGHT1")); 1708 order.appendChild(core.getDoc().createElement("SPECIALRIGHT2")); 1709 order.appendChild(core.getDoc().createElement("SPECIALRIGHT3")); 1710 order.appendChild(core.getDoc().createElement("SPECIALRIGHT4")); 1711 order.appendChild(core.getDoc().createElement("SPECIALRIGHT5")); 1712 order.appendChild(core.getDoc().createElement("USERID")); 1713 order.appendChild(core.getDoc().createElement("GROUPID")); 1714 order.appendChild(core.getDoc().createElement("SOURCE")); 1715 results = this.rightsView.selectEntriesWhereClause(pool, iroot); 1716 long userid = -2; 1717 long groupid = -2; 1718 ids = new ArrayList<String>(); 1719 for (Element cur : new ChildElementAdapter(results)) 1720 { 1721 // first time - just fill it 1722 if (userid == -2 && groupid == -2) 1723 { 1724 rightsView.elementid = DomUtil.getResultLong(cur, "element"); 1725 rightsView.module = DomUtil.getResultString(cur, "module"); 1726 rightsView.rightview = DomUtil.getResultBool(cur, "rightview"); 1727 rightsView.rightcreate = DomUtil.getResultBool(cur, "rightcreate"); 1728 rightsView.rightdelete = DomUtil.getResultBool(cur, "rightdelete"); 1729 rightsView.rightmodify = DomUtil.getResultBool(cur, "rightmodify"); 1730 rightsView.rightqm = DomUtil.getResultBool(cur, "rightqm"); 1731 rightsView.special1 = DomUtil.getResultBool(cur, "specialright1"); 1732 rightsView.special2 = DomUtil.getResultBool(cur, "specialright2"); 1733 rightsView.special3 = DomUtil.getResultBool(cur, "specialright3"); 1734 rightsView.special4 = DomUtil.getResultBool(cur, "specialright4"); 1735 rightsView.special5 = DomUtil.getResultBool(cur, "specialright5"); 1736 rightsView.source = DomUtil.getResultLong(cur, "source"); 1737 groupid = DomUtil.getResultLong(cur, "groupid"); 1738 userid = DomUtil.getResultLong(cur, "userid"); 1739 } 1740 else 1741 { 1742 if ( 1743 DomUtil.getResultLong(cur, "element") == rightsView.elementid && 1744 ((DomUtil.getResultString(cur, "module") != null && rightsView.module != null && 1745 DomUtil.getResultString(cur, "module").equals(rightsView.module)) || 1746 (DomUtil.getResultString(cur, "module") == null && rightsView.module == null ))&& 1747 DomUtil.getResultBool(cur, "rightview") == rightsView.rightview && 1748 DomUtil.getResultBool(cur, "rightcreate") == rightsView.rightcreate && 1749 DomUtil.getResultBool(cur, "rightdelete") == rightsView.rightdelete && 1750 DomUtil.getResultBool(cur, "rightmodify") == rightsView.rightmodify && 1751 DomUtil.getResultBool(cur, "rightqm") == rightsView.rightqm && 1752 DomUtil.getResultBool(cur, "specialright1") == rightsView.special1 && 1753 DomUtil.getResultBool(cur, "specialright2") == rightsView.special2 && 1754 DomUtil.getResultBool(cur, "specialright3") == rightsView.special3 && 1755 DomUtil.getResultBool(cur, "specialright4") == rightsView.special4 && 1756 DomUtil.getResultBool(cur, "specialright5") == rightsView.special5 && 1757 DomUtil.getResultLong(cur, "groupid") == groupid && 1758 DomUtil.getResultLong(cur, "userid") == userid && 1759 DomUtil.getResultLong(cur, "source") == rightsView.source) 1760 ids.add(DomUtil.getResultString(cur, "ID")); 1761 else 1762 { 1763 rightsView.elementid = DomUtil.getResultLong(cur, "element"); 1764 rightsView.module = DomUtil.getResultString(cur, "module"); 1765 rightsView.rightview = DomUtil.getResultBool(cur, "rightview"); 1766 rightsView.rightcreate = DomUtil.getResultBool(cur, "rightcreate"); 1767 rightsView.rightdelete = DomUtil.getResultBool(cur, "rightdelete"); 1768 rightsView.rightmodify = DomUtil.getResultBool(cur, "rightmodify"); 1769 rightsView.rightqm = DomUtil.getResultBool(cur, "rightqm"); 1770 rightsView.special1 = DomUtil.getResultBool(cur, "specialright1"); 1771 rightsView.special2 = DomUtil.getResultBool(cur, "specialright2"); 1772 rightsView.special3 = DomUtil.getResultBool(cur, "specialright3"); 1773 rightsView.special4 = DomUtil.getResultBool(cur, "specialright4"); 1774 rightsView.special5 = DomUtil.getResultBool(cur, "specialright5"); 1775 rightsView.source = DomUtil.getResultLong(cur, "source"); 1776 groupid = DomUtil.getResultLong(cur, "groupid"); 1777 userid = DomUtil.getResultLong(cur, "userid"); 1778 } 1779 } 1780 } 1781 // Deleting 1782 for (int i = 0; i < ids.size(); i++) 1783 { 1784 iroot = core.getDoc().createElement("DELETE"); 1785 iroot.appendChild(DomUtil.CreateNode(core.getDoc(), "ID", (String)ids.get(i))); 1786 rightsView.deleteEntry(pool, iroot); 1787 } 1788 } 1789 1790 1790 /** 1791 1791 * Returns an ArrayList of users who have the right stated in parameter right for the elementid … … 1838 1838 ids.add(DomUtil.getResultString(cur, "userid")); 1839 1839 } 1840 1840 1841 1841 if(ids.size() == 0) 1842 1842 return null; -
Core/trunk/src/main/java/corinis/modules/MailCenter.java
r629 r690 742 742 { 743 743 sendto = mcView.sendTo; 744 sendto = Utils.replaceString(sendto, "*", "@");744 sendto = sendto.replace('*', '@'); 745 745 // space and special chars like { or } 746 sendto = sendto.replace('"', ' '); 747 sendto = sendto.replace('{', ' '); 748 sendto = sendto.replace('}', ' '); 749 sendto = sendto.replace('\'', ' '); 746 750 sendto = Utils.replaceString(sendto, " ", ""); 747 sendto = Utils.replaceString(sendto, "{", "");748 sendto = Utils.replaceString(sendto, "}", "");749 sendto = Utils.replaceString(sendto, "§", "");750 751 System.out.println("Recipient: " + sendto); 751 752 } -
Core/trunk/src/main/java/corinis/modules/abstracts/DynamicField.java
r629 r690 554 554 * <FIELDS> 555 555 * <FIELD> 556 * <ID>557 * <FIELDNAME>558 * <DATA>556 * <ID> 557 * <FIELDNAME> 558 * <DATA> 559 559 * </FIELD> 560 560 * ... … … 650 650 * <RESULT> 651 651 * <USERID> 652 * <USERNAME>652 * <USERNAME> 653 653 * <FIELDS> 654 654 * <NAME> 655 * <VALUE>655 * <VALUE> 656 656 * ... 657 657 * </FIELDS> … … 1067 1067 * <FIELDS> 1068 1068 * <FIELD> 1069 *<ID>101114064280</ID>1070 * <NAME>surname</NAME>1071 * <REQUIRED>T</REQUIRED>1072 * <MINLENGTH>3</MINLENGTH>1073 * <AVAILCHARS>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZöüäÖÜÄ</AVAILCHARS>1074 * <DEFAULTVALUE />1075 * <DESCRIPTION>the surname of the user</DESCRIPTION>1069 * <ID>101114064280</ID> 1070 * <NAME>surname</NAME> 1071 * <REQUIRED>T</REQUIRED> 1072 * <MINLENGTH>3</MINLENGTH> 1073 * <AVAILCHARS>abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ </AVAILCHARS> 1074 * <DEFAULTVALUE /> 1075 * <DESCRIPTION>the surname of the user</DESCRIPTION> 1076 1076 * </FIELD> 1077 1077 * ... -
Core/trunk/src/main/java/corinis/modules/util/Eventer.java
r567 r690 101 101 String function = callingFunc(); 102 102 root.appendChild(getNoSuccessTree(function,errorId,errorFields)); 103 // TODO: throwEvent ändern?103 // TODO: change throwEvent? 104 104 throwEvent(function, Integer.toString(errorId), errorFields, module.getCore().getConnectionPool()); 105 105 return root; … … 122 122 } 123 123 root.appendChild(getNoSuccessTree(function, errorId, errorFields)); 124 // TODO: throwevent ändern?124 // TODO: change throwevent 125 125 throwEvent(function, Integer.toString(errorId), errorFields, module.getCore().getConnectionPool()); 126 126 return root; … … 146 146 } 147 147 root.appendChild(module.moduleData.getReqTree(module.getCore().getDoc())); 148 // TODO throwEvent ändern für reason?????148 // TODO change throwEvent? 149 149 throwEvent(function, Integer.toString(errorId), "", module.getCore().getConnectionPool()); 150 150 return root;
Note: See TracChangeset
for help on using the changeset viewer.
