List of usage examples for org.springframework.security.util FieldUtils setProtectedFieldValue
public static void setProtectedFieldValue(String protectedField, Object object, Object newValue)
From source file:com.qcadoo.customTranslation.internal.CustomTranslationManagementServiceImpl.java
@Override @Transactional//from w w w . j a v a2 s. com @SuppressWarnings("unchecked") public void addCustomTranslations(final String pluginIdentifier, final String locale, final Map<String, String> translations) { DataDefinition customTranslationDD = getCustomTranslationDD(); Session currentSession = getCurrentSession(customTranslationDD); List<String> existingKeys = currentSession.createQuery( "SELECT key FROM com.qcadoo.model.beans.qcadooCustomTranslation.QcadooCustomTranslationCustomTranslation " + "WHERE pluginIdentifier = :pluginIdentifier AND locale = :locale") .setString("pluginIdentifier", pluginIdentifier).setString("locale", locale).list(); for (Entry<String, String> translation : translations.entrySet()) { String key = translation.getKey(); String value = translation.getValue(); if (existingKeys.contains(key)) { continue; } Object entity = getInstanceForEntity(customTranslationDD); FieldUtils.setProtectedFieldValue(PLUGIN_IDENTIFIER, entity, pluginIdentifier); FieldUtils.setProtectedFieldValue(KEY, entity, key); FieldUtils.setProtectedFieldValue(PROPERTIES_TRANSLATION, entity, value); FieldUtils.setProtectedFieldValue(LOCALE, entity, locale); FieldUtils.setProtectedFieldValue(ACTIVE, entity, false); currentSession.save(entity); } }
From source file:org.artifactory.maven.index.RepoIndexer.java
public RepoIndexer(StoringRepo repo) { if (repo == null) { throw new IllegalArgumentException("Repo cannot be null"); }//from w ww. jav a 2 s. c o m this.repo = repo; //Unplexus defaultIndexerEngine = new DefaultIndexerEngine(); FieldUtils.setProtectedFieldValue("indexerEngine", this, defaultIndexerEngine); DefaultQueryCreator queryCreator = new DefaultQueryCreator(); FieldUtils.setProtectedFieldValue("logger", queryCreator, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console")); FieldUtils.setProtectedFieldValue("queryCreator", this, queryCreator); FieldUtils.setProtectedFieldValue("searcher", this, new DefaultSearchEngine()); //packer IncrementalHandler incrementalHandler = new DefaultIncrementalHandler(); FieldUtils.setProtectedFieldValue("logger", incrementalHandler, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console")); packer = new DefaultIndexPacker(); FieldUtils.setProtectedFieldValue("incrementalHandler", packer, incrementalHandler); FieldUtils.setProtectedFieldValue("logger", packer, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_WARN, "console")); ArtifactoryArtifactContextProducer artifactContextProducer = new ArtifactoryArtifactContextProducer(); scanner = new ArtifactoryContentScanner(artifactContextProducer); }
From source file:org.artifactory.repo.index.RepoIndexer.java
RepoIndexer(StoringRepo repo) { this.repo = repo; //Unplexus/* w w w .j av a2 s . co m*/ defaultIndexerEngine = new DefaultIndexerEngine(); FieldUtils.setProtectedFieldValue("indexerEngine", this, defaultIndexerEngine); DefaultQueryCreator queryCreator = new DefaultQueryCreator(); FieldUtils.setProtectedFieldValue("logger", queryCreator, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console")); FieldUtils.setProtectedFieldValue("queryCreator", this, queryCreator); FieldUtils.setProtectedFieldValue("searcher", this, new DefaultSearchEngine()); //packer IncrementalHandler incrementalHandler = new DefaultIncrementalHandler(); FieldUtils.setProtectedFieldValue("logger", incrementalHandler, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_INFO, "console")); packer = new DefaultIndexPacker(); FieldUtils.setProtectedFieldValue("incrementalHandler", packer, incrementalHandler); FieldUtils.setProtectedFieldValue("logger", packer, new ConsoleLogger(org.codehaus.plexus.logging.Logger.LEVEL_WARN, "console")); ArtifactoryArtifactContextProducer artifactContextProducer = new ArtifactoryArtifactContextProducer(); scanner = new ArtifactoryContentScanner(artifactContextProducer); }