Exemplo n.º 1
0
 public static Object wrap(Object target, ServiceConfiguration serviceConfiguration) {
   if (!isBamSupported()) {
     return target;
   }
   return Proxy.newProxyInstance(
       ClassLoaderUtils.getDefaultClassLoader(),
       ContextClassLoaderProxy.getInterfacesToProxy(target),
       new BAMClientProxy(target, serviceConfiguration));
 }
Exemplo n.º 2
0
 public KSBThreadPoolImpl() {
   super(
       DEFAULT_POOL_SIZE,
       DEFAULT_POOL_SIZE,
       60,
       TimeUnit.SECONDS,
       new PriorityBlockingQueue(1, new PriorityBlockingQueuePersistedMessageComparator()),
       new KSBThreadFactory(ClassLoaderUtils.getDefaultClassLoader()),
       new ThreadPoolExecutor.AbortPolicy());
 }
Exemplo n.º 3
0
 @Override
 public void validate() {
   super.validate();
   if (this.serviceInterfaces == null || this.serviceInterfaces.isEmpty()) {
     Class<?>[] interfaces = ClassLoaderUtils.getInterfacesToProxy(getService(), null, null);
     for (Class<?> serviceInterfaceClass : interfaces) {
       this.serviceInterfaces.add(serviceInterfaceClass.getName());
     }
   }
 }
Exemplo n.º 4
0
 protected void loadPlugins(File sharedPluginDirectory) {
   Map<String, File> pluginLocations = new TreeMap<String, File>(new PluginNameComparator());
   PluginZipFileFilter pluginFilter = new PluginZipFileFilter();
   Set<File> visitedFiles = new HashSet<File>();
   for (String pluginDir : pluginDirectories) {
     LOG.info("Reading plugins from " + pluginDir);
     File file = new File(pluginDir);
     if (visitedFiles.contains(file)) {
       LOG.info("Skipping visited directory: " + pluginDir);
       continue;
     }
     visitedFiles.add(file);
     if (!file.exists() || !file.isDirectory()) {
       LOG.warn(file.getAbsoluteFile() + " is not a valid plugin directory.");
       continue;
     }
     File[] pluginZips = file.listFiles(pluginFilter);
     for (int i = 0; i < pluginZips.length; i++) {
       File pluginZip = pluginZips[i];
       int indexOf = pluginZip.getName().lastIndexOf(".zip");
       String pluginName = pluginZip.getName().substring(0, indexOf);
       if (pluginLocations.containsKey(pluginName)) {
         LOG.warn(
             "There already exists an installed plugin with the name '"
                 + pluginName
                 + "', ignoring plugin "
                 + pluginZip.getAbsolutePath());
         continue;
       }
       pluginLocations.put(pluginName, pluginZip);
     }
   }
   for (String pluginName : pluginLocations.keySet()) {
     File pluginZipFile = pluginLocations.get(pluginName);
     try {
       LOG.info("Loading plugin '" + pluginName + "'");
       ClassLoader parentClassLoader = ClassLoaderUtils.getDefaultClassLoader();
       Config parentConfig = ConfigContext.getCurrentContextConfig();
       ZipFilePluginLoader loader =
           new ZipFilePluginLoader(
               pluginZipFile, sharedPluginDirectory, parentClassLoader, parentConfig);
       PluginEnvironment environment = new PluginEnvironment(loader, this);
       try {
         environment.load();
       } finally {
         // regardless of whether the plugin loads or not, let's add it to the environment
         addPluginEnvironment(environment);
       }
     } catch (Exception e) {
       LOG.error("Failed to read workflow plugin '" + pluginName + "'", e);
     }
   }
 }
  /**
   * @see
   *     org.kuali.rice.krad.service.DataDictionaryService#getAttributeValuesScopeId(java.lang.Class,
   *     java.lang.String)
   */
  public Class<? extends KeyValuesFinder> getAttributeValuesFinderClass(
      String entryName, String attributeName) {
    Class valuesFinderClass = null;

    AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
    if (attributeDefinition != null) {
      String valuesFinderClassName = attributeDefinition.getControl().getValuesFinderClass();
      valuesFinderClass = ClassLoaderUtils.getClass(valuesFinderClassName);
    }

    return valuesFinderClass;
  }
  /**
   * @see org.kuali.rice.krad.service.DataDictionaryService#getAttributeFormatter(java.lang.String)
   */
  public Class<? extends Formatter> getAttributeFormatter(String entryName, String attributeName) {
    Class formatterClass = null;

    AttributeDefinition attributeDefinition = getAttributeDefinition(entryName, attributeName);
    if (attributeDefinition != null) {
      if (attributeDefinition.hasFormatterClass()) {
        formatterClass = ClassLoaderUtils.getClass(attributeDefinition.getFormatterClass());
      }
    }

    return formatterClass;
  }
Exemplo n.º 7
0
 @Override
 public void start() throws Exception {
   if (serviceDefinitions != null && !serviceDefinitions.isEmpty()) {
     LOG.debug(
         "Configuring "
             + serviceDefinitions.size()
             + " services for application id "
             + CoreConfigHelper.getApplicationId()
             + " using config for classloader "
             + ClassLoaderUtils.getDefaultClassLoader());
     KsbApiServiceLocator.getServiceBus().publishServices(serviceDefinitions, true);
     super.start();
   }
 }
  @Override
  protected void prepareData(ProposalDevelopmentDocument document) throws Exception {

    Narrative narrative = new Narrative();
    List<Narrative> naList = new ArrayList<Narrative>();
    NarrativeAttachment narrativeAttachment = new NarrativeAttachment();
    DefaultResourceLoader resourceLoader =
        new DefaultResourceLoader(ClassLoaderUtils.getDefaultClassLoader());
    Resource resource = resourceLoader.getResource(S2STestConstants.ATT_PACKAGE + "/exercise1.pdf");
    InputStream inStream = resource.getInputStream();
    BufferedInputStream bis = new BufferedInputStream(inStream);
    byte[] narrativePdf = new byte[bis.available()];
    narrativeAttachment.setNarrativeData(narrativePdf);
    narrativeAttachment.setProposalNumber(document.getDevelopmentProposal().getProposalNumber());
    narrativeAttachment.setModuleNumber(1);
    saveBO(narrativeAttachment);

    List<NarrativeAttachment> narrativeList = new ArrayList<NarrativeAttachment>();
    narrativeList.add(narrativeAttachment);
    narrative.setProposalNumber(document.getDevelopmentProposal().getProposalNumber());
    narrative.setModuleNumber(1);
    narrative.setModuleSequenceNumber(1);
    narrative.setModuleStatusCode("C");
    narrative.setNarrativeTypeCode("39");
    narrative.setNarrativeAttachmentList(narrativeList);
    narrative.setObjectId("12345678890abcd");
    narrative.setFileName("exercise1");
    NarrativeType narrativeType = new NarrativeType();
    narrativeType.setNarrativeTypeCode("39");
    narrativeType.setAllowMultiple("Y");
    narrativeType.setSystemGenerated("N");
    narrativeType.setDescription("Testing for Project Attachment");
    getService(DataObjectService.class).save(narrativeType);
    narrative.setNarrativeType(narrativeType);
    narrative.setNarrativeTypeCode("39");
    naList.add(narrative);

    document.getDevelopmentProposal().setNarratives(naList);
    saveBO(document.getDevelopmentProposal());
  }
Exemplo n.º 9
0
  @Override
  protected void prepareData(ProposalDevelopmentDocument document) throws Exception {

    Organization organization =
        getService(DataObjectService.class)
            .findUnique(
                Organization.class,
                QueryByCriteria.Builder.forAttribute("organizationId", "000001").build());
    document.getDevelopmentProposal().getApplicantOrganization().setOrganization(organization);

    NarrativeAttachment narrativeAttachment = new NarrativeAttachment();
    DefaultResourceLoader resourceLoader =
        new DefaultResourceLoader(ClassLoaderUtils.getDefaultClassLoader());
    Resource resource = resourceLoader.getResource(S2STestConstants.ATT_PACKAGE + "/exercise2.pdf");
    InputStream inputStream = resource.getInputStream();
    BufferedInputStream bis = new BufferedInputStream(inputStream);
    byte[] narrativePdf = new byte[bis.available()];
    narrativeAttachment.setData(narrativePdf);
    narrativeAttachment.setName("exercise1");
    Narrative narrative = new Narrative();
    List<Narrative> narrativeList = new ArrayList<Narrative>();
    narrative.setDevelopmentProposal(document.getDevelopmentProposal());
    NarrativeType narrativeType =
        getService(DataObjectService.class)
            .findUnique(
                NarrativeType.class, QueryByCriteria.Builder.forAttribute("code", "7").build());
    narrative.setName("exercise1");
    narrative.setNarrativeType(narrativeType);
    narrative.setNarrativeTypeCode(narrativeType.getCode());
    narrative.setNarrativeAttachment(narrativeAttachment);
    narrative.setModuleNumber(1);
    narrative.setModuleSequenceNumber(1);
    narrative.setModuleStatusCode("C");
    narrativeList.add(narrative);
    document.getDevelopmentProposal().setNarratives(narrativeList);

    List<ProposalPerson> proposalPersons = new ArrayList<ProposalPerson>();
    ProposalPerson principalInvestigator = new ProposalPerson();
    principalInvestigator.setFirstName("ALAN");
    principalInvestigator.setLastName("MCAFEE");
    principalInvestigator.setProposalPersonRoleId("PI");
    principalInvestigator.setPersonId("0001");
    principalInvestigator.setRolodexId(0010);
    principalInvestigator.setProposalPersonNumber(1);
    principalInvestigator.setDevelopmentProposal(document.getDevelopmentProposal());
    proposalPersons.add(principalInvestigator);
    document.getDevelopmentProposal().setProposalPersons(proposalPersons);

    ProposalDevelopmentBudgetExt proposalDevelopmentBudgetExt = new ProposalDevelopmentBudgetExt();
    proposalDevelopmentBudgetExt.setDevelopmentProposal(document.getDevelopmentProposal());
    proposalDevelopmentBudgetExt.setBudgetVersionNumber(1);
    proposalDevelopmentBudgetExt.setBudgetStatus("1");
    proposalDevelopmentBudgetExt.setBudgetId(1L);
    proposalDevelopmentBudgetExt.setName("test Document Description");
    proposalDevelopmentBudgetExt.setOnOffCampusFlag("Y");
    proposalDevelopmentBudgetExt.setStartDate(new Date(new Long("1183316613046")));
    proposalDevelopmentBudgetExt.setEndDate(new Date(new Long("1214852613046")));
    proposalDevelopmentBudgetExt.setOhRateTypeCode("1");
    proposalDevelopmentBudgetExt.setOhRateClassCode("1");
    proposalDevelopmentBudgetExt.setModularBudgetFlag(false);
    proposalDevelopmentBudgetExt.setUrRateClassCode("1");

    List<BudgetPeriod> budgetPeriods = new ArrayList<BudgetPeriod>();
    BudgetPeriod budgetPeriod = new BudgetPeriod();
    budgetPeriod.setBudgetPeriodId(1L);
    budgetPeriod.setStartDate(new Date(new Long("1183316613046")));
    budgetPeriod.setEndDate(new Date(new Long("1214852613046")));
    budgetPeriod.setBudgetPeriod(1);

    budgetPeriod.setBudget(proposalDevelopmentBudgetExt);
    budgetPeriods.add(budgetPeriod);
    proposalDevelopmentBudgetExt.setBudgetPeriods(budgetPeriods);

    List<ProposalDevelopmentBudgetExt> proposalDevelopmentBudgetExtList =
        new ArrayList<ProposalDevelopmentBudgetExt>();
    proposalDevelopmentBudgetExtList.add(proposalDevelopmentBudgetExt);
    document.getDevelopmentProposal().setBudgets(proposalDevelopmentBudgetExtList);
    document.getDevelopmentProposal().setFinalBudget(proposalDevelopmentBudgetExt);
  }