Hello
I've succed to build a plugin which listens to the reposotory event's and build RSS Feed.
Now I use Files to store events and feed and I'd like to store them into a DB. I started by following this tutorial Active Object with RefApp. Then I found how could we configure Active Objects with Jira, Conflence Bamboo etc.
Now I wonder if AO require the same config with Stash and in this case why we don't find a link which demonstrates how can we configure AO within Stash ?
Thank you.
Cheers,
Ahmed.
Community moderators have prevented the ability to post new answers.
It ought to be listed through atlas-create-stash-plugin-module but isn't.
pom.xml
<dependency> <groupId>com.atlassian.activeobjects</groupId> <artifactId>activeobjects-plugin</artifactId> <scope>provided</scope> </dependency>
atlassian-plugin.xml
<component key="stashblah-ao-service" name="Stash Blah AO Service" class="com.blah.ao.StashBlahAOImpl"> <interface>com.blah.ao.IAoStashBlahService</interface> <description>Provides Stash Blah ActiveObject Services</description> </component>
<component-import key="ao" name="Active Objects service" interface="com.atlassian.activeobjects.external.ActiveObjects"/> <component key="tx-processor" name="Transactional Annotation Processor" class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor"> <description>Processes @Transactional annotations.</description> </component> <ao key="stashblah-ao-module"> <entity>com.blah.ao.Thing</entity> </ao>
IAoStashBlahService.java
@Transactional public interface IAoStashBlahService { ... }
Hi,
I have the same problem, but can't use the solution, because component definitions aren't allowed anymore. Any other solution?
thanks in advance
Hannes
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Hannes Niederhausen, you can still use the old style - all you have to do is comment out the <Atlassian-Plugin-Key> in the <instructions> section of the pom.xml file.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A fix for my issue is to separate the entity definition from the activeObjects component-import like this:
... <ao key="stash-ao-module"> <entity>stash.entity.DatabaseCheck</entity> </ao> ... <component-import key="activeObjects" interface="com.atlassian.activeobjects.external.ActiveObjects"/> ....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also want to add persistence to my existing plugin. When saving something my code produces a Runtime Exception:
... ... java.lang.RuntimeException: plugin [{stash.stash-db-consistency-bridge}] invoking ActiveObjects before <ao> configuration module is enabled or plugin is missing an <ao> configuration module. Note that scanning of entities from the ao.model package is no longer supported. ....
What could cause that?
Here some details of my persistence setup:
... <dependency> <groupId>com.atlassian.activeobjects</groupId> <artifactId>activeobjects-plugin</artifactId> <version>${ao.version}</version> <scope>provided</scope> </dependency> ... <ao.version>0.21.2</ao.version> ...
<component-import key="activeObjects" interface="com.atlassian.activeobjects.external.ActiveObjects"> <component key="tx-processor" name="Transactional Annotation Processor" class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor"> <description>Processes @Transactional annotations.</description> </component> <ao key="stash-ao-module"> <entity>stash.entity.DatabaseCheck</entity> </ao> </component-import> .... <component key="databaseCheckPersistenceManagerImpl" class="de.zalando.stash.persistence.DatabaseCheckPersistenceManagerImpl"> <interface>stash.persistence.DatabaseCheckPersistenceManager</interface> </component>
@Table("DBCheck") @Preload public interface DatabaseCheck extends Entity{ @NotNull public Integer getCheckId(); public void setCheckId(Integer id); @NotNull public String getStatus(); public void setStatus(String status); public String getNotes(); public void setNotes(String notes); }
public class DatabaseCheckPersistenceManagerImpl implements DatabaseCheckPersistenceManager { private final ActiveObjects activeObjects; public DatabaseCheckPersistenceManagerImpl(ActiveObjects activeObjects) { this.activeObjects = activeObjects; .... } public DatabaseCheck createOrUpdateDatabaseCheck(int checkID, String notes, String status) throws SQLException { // put method paremeters to dBParams array DatabaseCheck newDatabaseCheck = activeObjects.create( DatabaseCheck.class, dBParams ); .... }
the method createOrUpdateDatabaseCheck is called in class PullRequestEventListener:
public class PullRequestEventListener implements AsyncPostReceiveRepositoryHook { private final DatabaseCheckPersistenceManagerImpl databaseCheckPersistenceManager; .... public PullRequestEventListener(..., DatabaseCheckPersistenceManager databaseCheckPersistenceManager, ...) { this.databaseCheckPersistenceManager = databaseCheckPersistenceManager; .... } .... public boolean persistPostResponse(Map<String, String> response){ .... // retrieve details from response try { DatabaseCheck dbcheck = this.databaseCheckPersistenceManager.createOrUpdateDatabaseCheck(checkID, notes, status); return true; } catch (SQLException sqlException) { log.error("sql exception: {}: ", sqlException); } .... } ... }
that causes the RuntimeException above. I experience this runtime exception regardless of the type of class-member databaseCheckPersistenceManager: DatabaseCheckPersistenceManagerImpl or DatabaseCheckPersistenceManager.
I also wonder why the runtime excpetion does not appear in my test:
@RunWith(ActiveObjectsJUnitRunner.class) @Jdbc(DynamicJdbcConfiguration.class) @Data(InitialData.class) public class PersistenceTest { private EntityManager entityManager; private ActiveObjects activeObjects; private DatabaseCheckPersistenceManager databaseCheckPersistenceManager; ... @Before public void setUp() throws Exception { // ensure the runner set this already assertNotNull(entityManager); this.activeObjects = new TestActiveObjects(entityManager); this.databaseCheckPersistenceManager = new DatabaseCheckPersistenceManagerImpl(this.activeObjects); } ... @Test public void createDatabaseCheckTest() throws SQLException{ DatabaseCheck databaseCheckNotExisting = this.databaseCheckPersistenceManager.createOrUpdateDatabaseCheck(CHECKID_22, NOTES_4_CREATION, STATUS_SCHEDULED); DatabaseCheck databaseCheckCreated = this.databaseCheckPersistenceManager.getDatabaseCheck(CHECKID_22); assertTrue(CHECKID_22 == databaseCheckCreated.getCheckId()); ... } ... public static class InitialData implements DatabaseUpdater { @Override public void update(EntityManager entityManager) throws Exception { entityManager.migrate(DatabaseCheck.class); DatabaseCheck databaseCheck1 = entityManager.create( DatabaseCheck.class, new DBParam(CHECKID, CHECKID_10), new DBParam(STATUS, STATUS_CREATED), new DBParam(NOTES, NOTES_SOME_COMMENTS) ); ... // more test data } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.