@Override public IndexableDocument getIndexableDocument(String path) throws IndexingServiceException { try { // use internal findResource Name name = (Name) findResource(path, false); IndexableContent content = new IndexableContent(); content.addContentPart(name.getValue()); IndexableDocument doc = new IndexableDocument(); doc.setIndexableContent(content); doc.setResourceService(getServiceName()); doc.setResourceShortName(name.getValue()); doc.setResourceType(Name.RESOURCE_NAME); doc.setResourcePath(path); doc.setResourceFRI(name.getFactoryResourceIdentifier()); return doc; } catch (Exception e) { ctx.setRollbackOnly(); logger.error("unable to convert name to IndexableContent " + path, e); throw new IndexingServiceException("unable to convert name to IndexableContent" + path, e); } }
@Override @TransactionAttribute(TransactionAttributeType.SUPPORTS) public String sayHello(String path) throws GreetingServiceException { logger.info("sayHello(...) called"); logger.debug("params : path=" + path); try { // Checking if the connected user has the permission to say-hello the resource giving pep : String caller = membership.getProfilePathForConnectedIdentifier(); pep.checkSecurity(caller, path, "say-hello"); // Performing a lookup in the naming to recover the Resource Identifier FactoryResourceIdentifier identifier = binding.lookup(path); // Checking if this resource identifier is really a resource managed by this service (a Hello // resource) checkResourceType(identifier, Name.RESOURCE_NAME); // STARTING SPECIFIC EXTERNAL SERVICE RESOURCE LOADING OR METHOD CALLS Name name = em.find(Name.class, identifier.getId()); if (name == null) { throw new GreetingServiceException("unable to find a name for id " + identifier.getId()); } // END OF EXTERNAL SERVICE INVOCATION // Building hello message : String message = "Hello dear " + name.getValue() + " !!"; // Using the notification service to throw an event : notification.throwEvent( new Event( path, caller, Name.RESOURCE_NAME, Event.buildEventType(GreetingService.SERVICE_NAME, Name.RESOURCE_NAME, "say-hello"), "")); return message; } catch (Exception e) { // ctx.setRollbackOnly(); logger.error("unable to say hello to the name at path " + path, e); throw new GreetingServiceException("unable to say hello to the name at path " + path, e); } }