@Test public void buildWithoutScriptRight() throws Exception { Query query = mock(Query.class); when(this.secureQueryManager.createQuery(this.dbListClass.getSql(), Query.HQL)).thenReturn(query); assertSame(query, this.mocker.getComponentUnderTest().build(this.dbListClass)); verify(query).setWiki("math"); }
@Override public Query build(DBListClass dbListClass) throws QueryException { String statement = dbListClass.getSql(); DocumentReference authorReference = dbListClass.getOwnerDocument().getAuthorReference(); if (this.authorizationManager.hasAccess(Right.SCRIPT, authorReference, dbListClass.getReference())) { String namespace = this.entityReferenceSerializer.serialize(dbListClass.getDocumentReference()); try { statement = this.authorExecutor.call(() -> evaluateVelocityCode(dbListClass.getSql(), namespace), authorReference, dbListClass.getDocumentReference()); } catch (Exception e) { this.logger.warn( "Failed to evaluate the Velocity code from the query [{}]." + " Root cause is [{}]. Continuing with the raw query.", statement, ExceptionUtils.getRootCauseMessage(e)); } } Query query = this.secureQueryManager.createQuery(statement, Query.HQL); query.setWiki(dbListClass.getOwnerDocument().getDocumentReference().getWikiReference().getName()); return query; }
ExplicitlyAllowedValuesDBListQueryBuilder implements QueryBuilder<DBListClass> { @Override public Query build(DBListClass dbListClass) throws QueryException { String statement = dbListClass.getSql(); DocumentReference authorReference = dbListClass.getOwnerDocument().getAuthorReference(); if (this.authorizationManager.hasAccess(Right.SCRIPT, authorReference, dbListClass.getReference())) { String namespace = this.entityReferenceSerializer.serialize(dbListClass.getDocumentReference()); try { statement = this.authorExecutor.call(() -> evaluateVelocityCode(dbListClass.getSql(), namespace), authorReference, dbListClass.getDocumentReference()); } catch (Exception e) { this.logger.warn( "Failed to evaluate the Velocity code from the query [{}]." + " Root cause is [{}]. Continuing with the raw query.", statement, ExceptionUtils.getRootCauseMessage(e)); } } Query query = this.secureQueryManager.createQuery(statement, Query.HQL); query.setWiki(dbListClass.getOwnerDocument().getDocumentReference().getWikiReference().getName()); return query; } }
ExplicitlyAllowedValuesDBListQueryBuilder implements QueryBuilder<DBListClass> { @Override public Query build(DBListClass dbListClass) throws QueryException { String statement = dbListClass.getSql(); DocumentReference authorReference = dbListClass.getOwnerDocument().getAuthorReference(); if (this.authorizationManager.hasAccess(Right.SCRIPT, authorReference, dbListClass.getReference())) { String namespace = this.entityReferenceSerializer.serialize(dbListClass.getDocumentReference()); try { statement = this.authorExecutor.call(() -> evaluateVelocityCode(dbListClass.getSql(), namespace), authorReference, dbListClass.getDocumentReference()); } catch (Exception e) { this.logger.warn( "Failed to evaluate the Velocity code from the query [{}]." + " Root cause is [{}]. Continuing with the raw query.", statement, ExceptionUtils.getRootCauseMessage(e)); } } Query query = this.secureQueryManager.createQuery(statement, Query.HQL); query.setWiki(dbListClass.getOwnerDocument().getDocumentReference().getWikiReference().getName()); return query; }  }
ExplicitlyAllowedValuesDBListQueryBuilder implements QueryBuilder<DBListClass> { @Override public Query build(DBListClass dbListClass) throws QueryException { String statement = dbListClass.getSql(); DocumentReference authorReference = dbListClass.getOwnerDocument().getAuthorReference(); if (this.authorizationManager.hasAccess(Right.SCRIPT, authorReference, dbListClass.getReference())) { String namespace = this.entityReferenceSerializer.serialize(dbListClass.getDocumentReference()); try { statement = this.authorExecutor.call(() -> evaluateVelocityCode(dbListClass.getSql(), namespace), authorReference, dbListClass.getDocumentReference()); } catch (Exception e) { this.logger.warn( "Failed to evaluate the Velocity code from the query [{}]." + " Root cause is [{}]. Continuing with the raw query.", statement, ExceptionUtils.getRootCauseMessage(e)); } } Query query = this.secureQueryManager.createQuery(statement, Query.HQL); query.setWiki(dbListClass.getOwnerDocument().getDocumentReference().getWikiReference().getName()); return query; }  @Override Query build(DBListClass dbListClass); }
ExplicitlyAllowedValuesDBListQueryBuilder implements QueryBuilder<DBListClass> { @Override public Query build(DBListClass dbListClass) throws QueryException { String statement = dbListClass.getSql(); DocumentReference authorReference = dbListClass.getOwnerDocument().getAuthorReference(); if (this.authorizationManager.hasAccess(Right.SCRIPT, authorReference, dbListClass.getReference())) { String namespace = this.entityReferenceSerializer.serialize(dbListClass.getDocumentReference()); try { statement = this.authorExecutor.call(() -> evaluateVelocityCode(dbListClass.getSql(), namespace), authorReference, dbListClass.getDocumentReference()); } catch (Exception e) { this.logger.warn( "Failed to evaluate the Velocity code from the query [{}]." + " Root cause is [{}]. Continuing with the raw query.", statement, ExceptionUtils.getRootCauseMessage(e)); } } Query query = this.secureQueryManager.createQuery(statement, Query.HQL); query.setWiki(dbListClass.getOwnerDocument().getDocumentReference().getWikiReference().getName()); return query; }  @Override Query build(DBListClass dbListClass);  }