Changeset 1631 for ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
- Timestamp:
- 11/28/11 15:46:02 (13 years ago)
- Location:
- ComponentRegistry/branches/jeaferversion
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
ComponentRegistry/branches/jeaferversion/ComponentRegistry
- Property svn:ignore
-
old new 7 7 profiles.xml 8 8 nb-configuration.xml 9 nbactions-Run without tests.xml
-
- Property svn:ignore
-
ComponentRegistry/branches/jeaferversion/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/impl/database/ComponentRegistryDbImpl.java
r1604 r1631 29 29 import clarin.cmdi.componentregistry.impl.ComponentRegistryImplBase; 30 30 import clarin.cmdi.componentregistry.model.AbstractDescription; 31 import clarin.cmdi.componentregistry.model.CommentMapping.Comment; 31 32 import clarin.cmdi.componentregistry.model.ComponentDescription; 32 33 import clarin.cmdi.componentregistry.model.ProfileDescription; … … 49 50 @Autowired 50 51 private ComponentDescriptionDao componentDescriptionDao; 51 @Autowired 52 @Autowired 52 53 private UserDao userDao; 53 54 @Autowired … … 57 58 @Qualifier("profilesCache") 58 59 private CMDComponentSpecCache profilesCache; 60 @Autowired 61 private CommentsDao commentsDao; 62 //private CMDComponentSpecCache commentsCache; 59 63 60 64 /** … … 76 80 */ 77 81 public ComponentRegistryDbImpl(Number userId) { 78 82 this.userId = userId; 79 83 } 80 84 81 85 @Override 82 86 public List<ProfileDescription> getProfileDescriptions() throws ComponentRegistryException { 83 84 85 86 87 88 89 90 91 92 } 93 87 try { 88 if (isPublic()) { 89 return profileDescriptionDao.getPublicProfileDescriptions(); 90 } else { 91 return profileDescriptionDao.getUserspaceDescriptions(getUserId()); 92 } 93 } catch (DataAccessException ex) { 94 throw new ComponentRegistryException("Database access error while trying to get profile descriptions", ex); 95 } 96 } 97 94 98 @Override 95 99 public ProfileDescription getProfileDescription(String id) throws ComponentRegistryException { 96 97 98 99 100 100 try { 101 return profileDescriptionDao.getByCmdId(id, getUserId()); 102 } catch (DataAccessException ex) { 103 throw new ComponentRegistryException("Database access error while trying to get profile description", ex); 104 } 101 105 } 102 106 103 107 @Override 104 108 public List<ComponentDescription> getComponentDescriptions() throws ComponentRegistryException { 105 106 107 108 109 110 111 112 113 109 try { 110 if (isPublic()) { 111 return componentDescriptionDao.getPublicComponentDescriptions(); 112 } else { 113 return componentDescriptionDao.getUserspaceDescriptions(getUserId()); 114 } 115 } catch (DataAccessException ex) { 116 throw new ComponentRegistryException("Database access error while trying to get component descriptions", ex); 117 } 114 118 } 115 119 116 120 @Override 117 121 public ComponentDescription getComponentDescription(String id) throws ComponentRegistryException { 118 try { 119 return componentDescriptionDao.getByCmdId(id, getUserId()); 120 } catch (DataAccessException ex) { 121 throw new ComponentRegistryException("Database access error while trying to get component description", ex); 122 } 123 } 122 try { 123 return componentDescriptionDao.getByCmdId(id, getUserId()); 124 } catch (DataAccessException ex) { 125 throw new ComponentRegistryException("Database access error while trying to get component description", ex); 126 } 127 } 128 129 @Override 130 public List<Comment> getCommentsInProfile(String profileId) throws ComponentRegistryException { 131 try { 132 return commentsDao.getCommentsFromProfile(profileId); 133 } catch (DataAccessException ex) { 134 throw new ComponentRegistryException("Database access error while trying to get comment from profile", ex); 135 } 136 } 137 138 @Override 139 public Comment getSpecifiedCommentInProfile(String commentId) throws ComponentRegistryException { 140 try { 141 return commentsDao.getSpecifiedCommentFromProfile(commentId); 142 } catch (DataAccessException ex) { 143 throw new ComponentRegistryException("Database access error while trying to get comment from component", ex); 144 } 145 } 146 147 @Override 148 public List<Comment> getCommentsInComponent(String componentId) throws ComponentRegistryException { 149 try { 150 return commentsDao.getCommentsFromComponent(componentId); 151 } catch (DataAccessException ex) { 152 throw new ComponentRegistryException("Database access error while trying to get comment from component", ex); 153 } 154 } 155 156 @Override 157 public Comment getSpecifiedCommentInComponent(String commentId) throws ComponentRegistryException { 158 try { 159 return commentsDao.getSpecifiedCommentFromComponent(commentId); 160 } catch (DataAccessException ex) { 161 throw new ComponentRegistryException("Database access error while trying to get comment from component", ex); 162 } 163 } 164 165 // @Override 166 // public List<Comment> getComments() throws ComponentRegistryException { 167 // throw new UnsupportedOperationException("Not supported yet."); 168 // } 124 169 125 170 @Override 126 171 public CMDComponentSpec getMDProfile(String id) throws ComponentRegistryException { 127 128 129 130 131 132 133 134 135 136 137 172 if (inWorkspace(profileDescriptionDao, id)) { 173 CMDComponentSpec result = profilesCache.get(id); 174 if (result == null && !profilesCache.containsKey(id)) { 175 result = getUncachedMDProfile(id); 176 profilesCache.put(id, result); 177 } 178 return result; 179 } else { 180 // May exist, but not in this workspace 181 return null; 182 } 138 183 } 139 184 140 185 public CMDComponentSpec getUncachedMDProfile(String id) throws ComponentRegistryException { 141 142 143 144 145 186 try { 187 return getUncachedMDComponent(id, profileDescriptionDao); 188 } catch (DataAccessException ex) { 189 throw new ComponentRegistryException("Database access error while trying to get profile", ex); 190 } 146 191 } 147 192 148 193 @Override 149 194 public CMDComponentSpec getMDComponent(String id) throws ComponentRegistryException { 150 151 152 153 154 155 156 157 158 159 195 if (inWorkspace(componentDescriptionDao, id)) { 196 CMDComponentSpec result = componentsCache.get(id); 197 if (result == null && !componentsCache.containsKey(id)) { 198 result = getUncachedMDComponent(id); 199 componentsCache.put(id, result); 200 } 201 return result; 202 } else { 203 return null; 204 } 160 205 } 161 206 162 207 public CMDComponentSpec getUncachedMDComponent(String id) throws ComponentRegistryException { 163 try { 164 return getUncachedMDComponent(id, componentDescriptionDao); 165 } catch (DataAccessException ex) { 166 throw new ComponentRegistryException("Database access error while trying to get component", ex); 167 } 168 } 208 try { 209 return getUncachedMDComponent(id, componentDescriptionDao); 210 } catch (DataAccessException ex) { 211 throw new ComponentRegistryException("Database access error while trying to get component", ex); 212 } 213 } 214 215 //// @Override 216 //// public CMDComponentSpec getMDComment(String id) throws ComponentRegistryException { 217 ////// if (inWorkspace(commentsDao, id)) { 218 ////// CMDComponentSpec result = commentsCache.get(id); 219 ////// if (result == null && !commentsCache.containsKey(id)) { 220 ////// result = getUncachedMDComment(id); 221 ////// commentsCache.put(id, result); 222 ////// } 223 ////// return result; 224 ////// } else { 225 ////// // May exist, but not in this workspace 226 //// return null; 227 ////// } 228 //// } 229 // 230 //// public CMDComponentSpec getUncachedMDComment(String id) throws ComponentRegistryException { 231 //// try { 232 //// return getUncachedMDComment(id, commentsDao); 233 //// } catch (DataAccessException ex) { 234 //// throw new ComponentRegistryException("Database access error while trying to get component", ex); 235 // } 236 // } 169 237 170 238 @Override 171 239 public int register(AbstractDescription description, CMDComponentSpec spec) { 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 240 enrichSpecHeader(spec, description); 241 try { 242 String xml = componentSpecToString(spec); 243 // Convert principal name to user record id 244 Number uid = convertUserIdInDescription(description); 245 getDaoForDescription(description).insertDescription(description, xml, isPublic(), uid); 246 invalidateCache(description); 247 return 0; 248 } catch (DataAccessException ex) { 249 LOG.error("Database error while registering component", ex); 250 return -1; 251 } catch (JAXBException ex) { 252 LOG.error("Error while registering component", ex); 253 return -2; 254 } catch (UnsupportedEncodingException ex) { 255 LOG.error("Error while registering component", ex); 256 return -3; 257 } 190 258 } 191 259 … … 201 269 */ 202 270 private Number convertUserIdInDescription(AbstractDescription description) throws DataAccessException { 203 204 205 206 207 208 209 210 211 212 213 214 215 271 Number uid = null; 272 if (description.getUserId() != null) { 273 User user = userDao.getByPrincipalName(description.getUserId()); 274 if (user != null) { 275 uid = user.getId(); 276 } 277 } else { 278 uid = userId; 279 } 280 if (uid != null) { 281 description.setUserId(uid.toString()); 282 } 283 return uid; 216 284 } 217 285 218 286 @Override 219 287 public int update(AbstractDescription description, CMDComponentSpec spec, Principal principal, boolean forceUpdate) { 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 288 try { 289 checkAuthorisation(description, principal); 290 checkAge(description, principal); 291 // For public components, check if used in other components or profiles (unless forced) 292 if (!forceUpdate && this.isPublic() && !description.isProfile()) { 293 checkStillUsed(description.getId()); 294 } 295 AbstractDescriptionDao<?> dao = getDaoForDescription(description); 296 dao.updateDescription(getIdForDescription(description), description, componentSpecToString(spec)); 297 invalidateCache(description); 298 return 0; 299 } catch (JAXBException ex) { 300 LOG.error("Error while updating component", ex); 301 return -1; 302 } catch (UnsupportedEncodingException ex) { 303 LOG.error("Error while updating component", ex); 304 return -1; 305 } catch (IllegalArgumentException ex) { 306 LOG.error("Error while updating component", ex); 307 return -1; 308 } catch (UserUnauthorizedException e) { 309 LOG.error("Error while updating component", e); 310 return -1; 311 } catch (DeleteFailedException e) { 312 LOG.error("Error while updating component", e); 313 return -1; 314 } catch (ComponentRegistryException e) { 315 LOG.error("Error while updating component", e); 316 return -1; 317 } 250 318 } 251 319 252 320 @Override 253 321 public int publish(AbstractDescription desc, CMDComponentSpec spec, Principal principal) { 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 322 int result = 0; 323 AbstractDescriptionDao<?> dao = getDaoForDescription(desc); 324 if (!isPublic()) { // if already in public workspace there is nothing todo 325 desc.setHref(AbstractDescription.createPublicHref(desc.getHref())); 326 Number id = getIdForDescription(desc); 327 try { 328 // Update description & content 329 dao.updateDescription(id, desc, componentSpecToString(spec)); 330 // Set to public 331 dao.setPublished(id, true); 332 } catch (DataAccessException ex) { 333 LOG.error("Database error while updating component", ex); 334 return -1; 335 } catch (JAXBException ex) { 336 LOG.error("Error while updating component", ex); 337 return -2; 338 } catch (UnsupportedEncodingException ex) { 339 LOG.error("Error while updating component", ex); 340 return -3; 341 } 342 } 343 return result; 276 344 } 277 345 278 346 @Override 279 347 public void getMDProfileAsXml(String profileId, OutputStream output) throws ComponentRegistryException { 280 281 348 CMDComponentSpec expandedSpec = CMDComponentSpecExpanderDbImpl.expandProfile(profileId, this); 349 writeXml(expandedSpec, output); 282 350 } 283 351 284 352 @Override 285 353 public void getMDProfileAsXsd(String profileId, OutputStream outputStream) throws ComponentRegistryException { 286 287 354 CMDComponentSpec expandedSpec = CMDComponentSpecExpanderDbImpl.expandProfile(profileId, this); 355 writeXsd(expandedSpec, outputStream); 288 356 } 289 357 290 358 @Override 291 359 public void getMDComponentAsXml(String componentId, OutputStream output) throws ComponentRegistryException { 292 293 360 CMDComponentSpec expandedSpec = CMDComponentSpecExpanderDbImpl.expandComponent(componentId, this); 361 writeXml(expandedSpec, output); 294 362 } 295 363 296 364 @Override 297 365 public void getMDComponentAsXsd(String componentId, OutputStream outputStream) throws ComponentRegistryException { 298 299 366 CMDComponentSpec expandedSpec = CMDComponentSpecExpanderDbImpl.expandComponent(componentId, this); 367 writeXsd(expandedSpec, outputStream); 300 368 } 301 369 302 370 @Override 303 371 public void deleteMDProfile(String profileId, Principal principal) throws UserUnauthorizedException, DeleteFailedException, 304 ComponentRegistryException { 305 ProfileDescription desc = getProfileDescription(profileId); 306 if (desc != null) { 307 try { 308 checkAuthorisation(desc, principal); 309 checkAge(desc, principal); 310 profileDescriptionDao.setDeleted(desc, true); 311 invalidateCache(desc); 312 } catch (DataAccessException ex) { 313 throw new DeleteFailedException("Database access error while trying to delete profile", ex); 314 } 315 } 316 } 372 ComponentRegistryException { 373 ProfileDescription desc = getProfileDescription(profileId); 374 if (desc != null) { 375 try { 376 checkAuthorisation(desc, principal); 377 checkAge(desc, principal); 378 profileDescriptionDao.setDeleted(desc, true); 379 invalidateCache(desc); 380 } catch (DataAccessException ex) { 381 throw new DeleteFailedException("Database access error while trying to delete profile", ex); 382 } 383 } 384 } 385 386 // public void deleteMDComment(String commentId, Principal principal) throws UserUnauthorizedException, DeleteFailedException, ComponentRegistryException { 387 // Comment desc = getCommentsInComponent(commentId); 388 // if(desc != null) { 389 // try { 390 // checkAuthorisationComment(desc, principal); 391 // checkCommentAge(desc, principal); 392 // commentsDao.setDeleted(desc, true); 393 // invalidateCommentCache(desc); 394 // } catch (DataAccessException ex) { 395 // throw new DeleteFailedException("Database access error while trying to delete profile", ex); 396 // } 397 // } 398 // } 317 399 318 400 @Override 319 401 public void deleteMDComponent(String componentId, Principal principal, boolean forceDelete) throws UserUnauthorizedException, 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 402 DeleteFailedException, ComponentRegistryException { 403 ComponentDescription desc = componentDescriptionDao.getByCmdId(componentId); 404 if (desc != null) { 405 try { 406 checkAuthorisation(desc, principal); 407 checkAge(desc, principal); 408 409 if (!forceDelete) { 410 checkStillUsed(componentId); 411 } 412 componentDescriptionDao.setDeleted(desc, true); 413 invalidateCache(desc); 414 } catch (DataAccessException ex) { 415 throw new DeleteFailedException("Database access error while trying to delete component", ex); 416 } 417 } 336 418 } 337 419 338 420 @Override 339 421 public boolean isPublic() { 340 422 return null == userId; 341 423 } 342 424 343 425 public void setPublic() { 344 426 this.userId = null; 345 427 } 346 428 … … 349 431 */ 350 432 public Number getUserId() { 351 433 return userId; 352 434 } 353 435 … … 358 440 */ 359 441 public void setUserId(Number user) { 360 442 this.userId = user; 361 443 } 362 444 363 445 private void invalidateCache(AbstractDescription description) { 364 if (description.isProfile()) { 365 profilesCache.remove(description.getId()); 366 } else { 367 componentsCache.remove(description.getId()); 368 } 369 } 446 if (description.isProfile()) { 447 profilesCache.remove(description.getId()); 448 } else { 449 componentsCache.remove(description.getId()); 450 } 451 } 452 453 // private void invalidateCommentCache(Comment comment) { 454 // commentsCache.remove(comment.getId()); 455 // } 370 456 371 457 private AbstractDescriptionDao<?> getDaoForDescription(AbstractDescription description) { 372 return description.isProfile() ? profileDescriptionDao : componentDescriptionDao; 373 } 458 return description.isProfile() ? profileDescriptionDao : componentDescriptionDao; 459 } 460 461 // private CommentsDao getDaoForCommentDescription(Comment comment) { 462 // return commentsDao; 463 // } 374 464 375 465 /** … … 384 474 */ 385 475 private Number getIdForDescription(AbstractDescription description) throws IllegalArgumentException { 386 Number dbId = null; 387 AbstractDescriptionDao<?> dao = getDaoForDescription(description); 388 try { 389 dbId = dao.getDbId(description.getId()); 390 } catch (DataAccessException ex) { 391 LOG.error("Error getting dbId for component with id " + description.getId(), ex); 392 } 393 if (dbId == null) { 394 throw new IllegalArgumentException("Could not get database Id for description"); 395 } else { 396 return dbId; 397 } 398 } 399 476 Number dbId = null; 477 AbstractDescriptionDao<?> dao = getDaoForDescription(description); 478 try { 479 dbId = dao.getDbId(description.getId()); 480 } catch (DataAccessException ex) { 481 LOG.error("Error getting dbId for component with id " + description.getId(), ex); 482 } 483 if (dbId == null) { 484 throw new IllegalArgumentException("Could not get database Id for description"); 485 } else { 486 return dbId; 487 } 488 } 489 490 491 // private Number getIdForCommentDescription(Comment comment) throws IllegalArgumentException { 492 // Number dbId = null; 493 // CommentsDao dao = getDaoForCommentDescription(comment); 494 // try { 495 // dbId = dao.getDbId(comment.getId()); 496 // } catch (DataAccessException ex) { 497 // LOG.error("Error getting dbId for comment with id " + comment.getId(), ex); 498 // } 499 // if (dbId == null) { 500 // throw new IllegalArgumentException("Could not get database Id for description"); 501 // } else { 502 // return dbId; 503 // } 504 // } 505 400 506 private String componentSpecToString(CMDComponentSpec spec) throws UnsupportedEncodingException, JAXBException { 401 402 403 404 507 ByteArrayOutputStream os = new ByteArrayOutputStream(); 508 MDMarshaller.marshal(spec, os); 509 String xml = os.toString("UTF-8"); 510 return xml; 405 511 } 406 512 407 513 private CMDComponentSpec getUncachedMDComponent(String id, AbstractDescriptionDao dao) { 408 String xml = dao.getContent(false, id); 409 if (xml != null) { 410 try { 411 InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8")); 412 return MDMarshaller.unmarshal(CMDComponentSpec.class, is, null); 413 414 } catch (JAXBException ex) { 415 LOG.error(null, ex); 416 } catch(UnsupportedEncodingException ex){ 417 LOG.error(null, ex); 418 } 419 } 420 return null; 421 } 514 String xml = dao.getContent(false, id); 515 if (xml != null) { 516 try { 517 InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8")); 518 return MDMarshaller.unmarshal(CMDComponentSpec.class, is, null); 519 520 } catch (JAXBException ex) { 521 LOG.error(null, ex); 522 } catch (UnsupportedEncodingException ex) { 523 LOG.error(null, ex); 524 } 525 } 526 return null; 527 } 528 529 // private CMDComponentSpec getUncachedMDComment(String id, CommentsDao dao) { 530 // String xml = dao.getContent(false, id); 531 // if (xml != null) { 532 // try { 533 // InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8")); 534 // return MDMarshaller.unmarshal(CMDComponentSpec.class, is, null); 535 // 536 // } catch (JAXBException ex) { 537 // LOG.error(null, ex); 538 // } catch (UnsupportedEncodingException ex) { 539 // LOG.error(null, ex); 540 // } 541 // } 542 // return null; 543 // } 422 544 423 545 private void checkAuthorisation(AbstractDescription desc, Principal principal) throws UserUnauthorizedException { 424 if (!isOwnerOfDescription(desc, principal.getName()) && !configuration.isAdminUser(principal)) { 425 throw new UserUnauthorizedException("Unauthorized operation user '" + principal.getName() 426 + "' is not the creator (nor an administrator) of the " + (desc.isProfile() ? "profile" : "component") + "(" + desc 427 + ")."); 428 } 429 } 546 if (!isOwnerOfDescription(desc, principal.getName()) && !configuration.isAdminUser(principal)) { 547 throw new UserUnauthorizedException("Unauthorized operation user '" + principal.getName() 548 + "' is not the creator (nor an administrator) of the " + (desc.isProfile() ? "profile" : "component") + "(" + desc 549 + ")."); 550 } 551 } 552 553 // private void checkAuthorisationComment(Comment desc, Principal principal)throws UserUnauthorizedException { 554 // if (!isOwnerOfComment(desc, principal.getName()) && !configuration.isAdminUser(principal)) { 555 // throw new UserUnauthorizedException("Unauthorized operation user '" + principal.getName() 556 // + "' is not the creator (nor an administrator) of the " + (desc.getId()) + "(" + desc 557 // + ")."); 558 // } 559 // } 430 560 431 561 private boolean isOwnerOfDescription(AbstractDescription desc, String principalName) { 432 String owner = getDaoForDescription(desc).getOwnerPrincipalName(getIdForDescription(desc)); 433 return owner != null // If owner is null, no one can be owner 434 && principalName.equals(owner); 435 } 562 String owner = getDaoForDescription(desc).getOwnerPrincipalName(getIdForDescription(desc)); 563 return owner != null // If owner is null, no one can be owner 564 && principalName.equals(owner); 565 } 566 567 // private boolean isOwnerOfComment(Comment desc, String principalName) { 568 // String owner = getDaoForCommentDescription(desc).getOwnerPrincipalName(getIdForCommentDescription(desc)); 569 // return owner != null // If owner is null, no one can be owner 570 // && principalName.equals(owner); 571 // } 436 572 437 573 private void checkAge(AbstractDescription desc, Principal principal) throws DeleteFailedException { 438 if (isPublic() && !configuration.isAdminUser(principal)) { 439 try { 440 Date regDate = AbstractDescription.getDate(desc.getRegistrationDate()); 441 Calendar calendar = Calendar.getInstance(); 442 calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); 443 if (regDate.before(calendar.getTime())) { // More then month old 444 throw new DeleteFailedException( 445 "The " 446 + (desc.isProfile() ? "Profile" : "Component") 447 + " is more then a month old and cannot be deleted anymore. It might have been used to create metadata, deleting it would invalidate that metadata."); 448 } 449 } catch (ParseException e) { 450 LOG.error("Cannot parse date of " + desc + " Error:" + e); 451 } 452 } 453 } 574 if (isPublic() && !configuration.isAdminUser(principal)) { 575 try { 576 Date regDate = AbstractDescription.getDate(desc.getRegistrationDate()); 577 Calendar calendar = Calendar.getInstance(); 578 calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); 579 if (regDate.before(calendar.getTime())) { // More then month old 580 throw new DeleteFailedException( 581 "The " 582 + (desc.isProfile() ? "Profile" : "Component") 583 + " is more then a month old and cannot be deleted anymore. It might have been used to create metadata, deleting it would invalidate that metadata."); 584 } 585 } catch (ParseException e) { 586 LOG.error("Cannot parse date of " + desc + " Error:" + e); 587 } 588 } 589 } 590 591 // private void checkCommentAge(Comment desc, Principal principal) throws DeleteFailedException { 592 // if (isPublic() && !configuration.isAdminUser(principal)) { 593 // try { 594 // Date regDate = Comment.getDate(desc.getCommentDate()); 595 // Calendar calendar = Calendar.getInstance(); 596 // calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); 597 // if (regDate.before(calendar.getTime())) { // More then month old 598 // throw new DeleteFailedException( 599 // "The " 600 // + (desc.getId()) 601 // + " is more then a month old and cannot be deleted anymore."); 602 // } 603 // } catch (ParseException e) { 604 // LOG.error("Cannot parse date of " + desc + " Error:" + e); 605 // } 606 // } 607 // } 454 608 455 609 private boolean inWorkspace(AbstractDescriptionDao<?> dao, String cmdId) { 456 if (isPublic()) { 457 return dao.isPublic(cmdId); 458 } else { 459 return dao.isInUserSpace(cmdId, getUserId()); 460 } 461 } 610 if (isPublic()) { 611 return dao.isPublic(cmdId); 612 } else { 613 return dao.isInUserSpace(cmdId, getUserId()); 614 } 615 } 616 617 // private boolean inWorkspace(CommentsDao dao, String cmdId) { 618 // if (isPublic()) { 619 // return dao.isPublic(cmdId); 620 // } else { 621 // return dao.isInUserSpace(cmdId, getUserId()); 622 // } 623 // } 462 624 463 625 @Override 464 626 public String getName() { 465 466 467 468 469 627 if (isPublic()) { 628 return ComponentRegistry.PUBLIC_NAME; 629 } else { 630 return "User " + getUserId() + " Registry"; 631 } 470 632 } 471 633 472 634 @Override 473 635 public List<ProfileDescription> getDeletedProfileDescriptions() { 474 636 return profileDescriptionDao.getDeletedDescriptions(getUserId()); 475 637 } 476 638 477 639 @Override 478 640 public List<ComponentDescription> getDeletedComponentDescriptions() { 479 641 return componentDescriptionDao.getDeletedDescriptions(getUserId()); 480 642 } 481 643 }
Note: See TracChangeset
for help on using the changeset viewer.