@Test public void testNonMatchingAsset_AllRepositories() throws Exception { when(selectorManager.evaluate(any(), any())).thenReturn(true); Map<String, List<String>> repoToContainedGroupMap = new HashMap<>(); repoToContainedGroupMap.put(REPOSITORY_NAME, Collections.emptyList()); assertThat(underTest.execute(underTest, null, null, new Object[]{ assetDocument, "jexlexpression", "*", repoToContainedGroupMap }, null), is(false)); }
@Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; String assetRepository = getAssetRepository(asset); if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); }
ContentExpressionFunction extends OSQLFunctionAbstract { @Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; String assetRepository = getAssetRepository(asset); if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); } }
ContentExpressionFunction extends OSQLFunctionAbstract { @Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; String assetRepository = getAssetRepository(asset); if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); } @Inject  ContentExpressionFunction(final VariableResolverAdapterManager variableResolverAdapterManager,
                                   final SelectorManager selectorManager,
                                   final OrientContentAuthHelper contentAuthHelper); }
ContentExpressionFunction extends OSQLFunctionAbstract { @Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; String assetRepository = getAssetRepository(asset); if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); } @Inject  ContentExpressionFunction(final VariableResolverAdapterManager variableResolverAdapterManager,
                                   final SelectorManager selectorManager,
                                   final OrientContentAuthHelper contentAuthHelper); @Override Object execute(final Object iThis,
                        final OIdentifiable iCurrentRecord,
                        final Object iCurrentResult,
                        final Object[] iParams,
                        final OCommandContext iContext); @Override String getSyntax(); }
ContentExpressionFunction extends OSQLFunctionAbstract { @Override public Object execute(final Object iThis, final OIdentifiable iCurrentRecord, final Object iCurrentResult, final Object[] iParams, final OCommandContext iContext) { OIdentifiable identifiable = (OIdentifiable) iParams[0]; ODocument asset = identifiable.getRecord(); RepositorySelector repositorySelector = RepositorySelector.fromSelector((String) iParams[2]); String jexlExpression = (String) iParams[1]; List<String> membersForAuth; if (!repositorySelector.isAllRepositories()) { membersForAuth = Arrays.asList(repositorySelector.getName()); } else { @SuppressWarnings("unchecked") Map<String, List<String>> repoToContainedGroupMap = (Map<String, List<String>>) iParams[3]; String assetRepository = getAssetRepository(asset); if (assetRepository == null) { log.error("Asset {} references no repository", getAssetName(asset)); return false; } membersForAuth = repoToContainedGroupMap.get(assetRepository); if (membersForAuth == null) { log.error("Asset {} references an invalid repository: {}", getAssetName(asset), assetRepository); return false; } } return contentAuthHelper.checkPathPermissions(asset.field(P_NAME), asset.field(P_FORMAT), membersForAuth.toArray(new String[membersForAuth.size()])) && checkJexlExpression(asset, jexlExpression, asset.field(AssetEntityAdapter.P_FORMAT, String.class)); } @Inject  ContentExpressionFunction(final VariableResolverAdapterManager variableResolverAdapterManager,
                                   final SelectorManager selectorManager,
                                   final OrientContentAuthHelper contentAuthHelper); @Override Object execute(final Object iThis,
                        final OIdentifiable iCurrentRecord,
                        final Object iCurrentResult,
                        final Object[] iParams,
                        final OCommandContext iContext); @Override String getSyntax(); static final String NAME; }