@Test
  public void testConvertDatabaseConnectionBooleanString() {
    DatabaseConnection dbProvider = ConnectionFactory.eINSTANCE.createDatabaseConnection();

    // mock CoreRuntimePlugin
    CoreRuntimePlugin instanceMock = Mockito.mock(CoreRuntimePlugin.class);
    PowerMockito.mockStatic(CoreRuntimePlugin.class);
    Mockito.when(CoreRuntimePlugin.getInstance()).thenReturn(instanceMock);
    Mockito.when(instanceMock.getRepositoryService()).thenReturn(null);
    // ~CoreRuntimePlugin
    setJDBCMysqlConnection(dbProvider);
    IMetadataConnection convertMetadata = ConvertionHelper.convert(dbProvider, false, null);
    validJDBCMysqlConnection(convertMetadata, dbProvider);
  }
Esempio n. 2
0
  @Override
  public void logOnProject(Project project) throws LoginException, PersistenceException {
    setLoggedOnProject(false);

    // TODO: review the prefs
    // new StatusPreferenceInitializer().initializeDefaultPreferences();
    IStatusPreferenceInitService statusPreferenceInitService =
        CoreRuntimePlugin.getInstance().getStatusPreferenceInitService();
    if (statusPreferenceInitService != null) {
      statusPreferenceInitService.initStatusPreference();
    }
    String productVersion = VersionUtils.getVersion();
    IBrandingService brandingService = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IBrandingService.class)) {
      brandingService =
          (IBrandingService) GlobalServiceRegister.getDefault().getService(IBrandingService.class);
    }
    if (brandingService != null) {
      String version = brandingService.getFullProductName() + "-" + productVersion; // $NON-NLS-1$
      if (!version.equals(project.getEmfProject().getProductVersion())) {
        project.getEmfProject().setProductVersion(version);
        project.getEmfProject().getFolders().clear();
      }
    }
    // saveProject();

    setLoggedOnProject(true);
  }
 /**
  * Set the value of row limit back to default in preference.
  *
  * <p>yzhang Comment method "setLimitToDefault".
  */
 public static void setLimitToDefault() {
   XmlArray.rowLimit =
       CoreRuntimePlugin.getInstance()
           .getCoreService()
           .getPreferenceStore()
           .getInt(ITalendCorePrefConstants.PREVIEW_LIMIT);
 }
 /**
  * DOC mhelleboid Comment method "getRepositoryProject".
  *
  * @return
  */
 private Project getRepositoryProject() {
   RepositoryContext repositoryContext =
       (RepositoryContext)
           CoreRuntimePlugin.getInstance()
               .getContext()
               .getProperty(Context.REPOSITORY_CONTEXT_KEY);
   return repositoryContext.getProject();
 }
  public synchronized MavenResolver getMavenResolver() throws RuntimeException {
    if (mavenResolver == null) {
      BundleContext context = CoreRuntimePlugin.getInstance().getBundle().getBundleContext();
      ServiceReference<ManagedService> managedServiceRef =
          context.getServiceReference(ManagedService.class);
      if (managedServiceRef != null) {
        String repositories = "";
        NexusServerBean customServer = getCustomNexusServer();
        if (customServer != null) {
          // custom nexus server should use snapshot repository
          repositories = customServer.getRepositoryUrl() + NexusConstants.SNAPSHOTS + ",";
        }
        final NexusServerBean officailServer = getLibrariesNexusServer();
        repositories = repositories + officailServer.getRepositoryUrl();

        ManagedService managedService = context.getService(managedServiceRef);
        Dictionary<String, String> props = new Hashtable<String, String>();
        props.put(
            ServiceConstants.PID + '.' + ServiceConstants.PROPERTY_REPOSITORIES, repositories);

        // get the setting file same as M2E preference in M2eUserSettingForTalendLoginTask.
        String settingsFile = MavenPlugin.getMavenConfiguration().getUserSettingsFile();
        if (settingsFile != null && new File(settingsFile).exists()) {
          props.put(
              ServiceConstants.PID + '.' + ServiceConstants.PROPERTY_SETTINGS_FILE, settingsFile);
        }

        try {
          managedService.updated(props);
        } catch (ConfigurationException e) {
          throw new RuntimeException("Failed to modifiy the service properties"); // $NON-NLS-1$
        }
      } else {
        throw new RuntimeException(
            "Failed to load the service :"
                + ManagedService.class.getCanonicalName()); // $NON-NLS-1$
      }

      ServiceReference<org.ops4j.pax.url.mvn.MavenResolver> mavenResolverService =
          context.getServiceReference(org.ops4j.pax.url.mvn.MavenResolver.class);
      if (mavenResolverService != null) {
        mavenResolver = context.getService(mavenResolverService);
      } else {
        throw new RuntimeException("Unable to acquire org.ops4j.pax.url.mvn.MavenResolver");
      }
    }

    return mavenResolver;
  }
  /**
   * DOC ggu Comment method "updateForRepository".
   *
   * <p>Worked for DetecteViewImpactAction
   *
   * @param node
   * @return
   */
  public boolean updateForRepository(IStructuredSelection selection, boolean needConfirm) {
    boolean forcePropagation = false;
    IRepositoryUpdateManagerProvider[] repositoryProviders = reader.getRepositoryProviders();
    for (IRepositoryUpdateManagerProvider provider : repositoryProviders) {
      if (provider.needForcePropagation(selection)) {
        forcePropagation = true;
      }
    }

    if (!forcePropagation && needConfirm) {
      IDesignerCoreService designerCoreService =
          CoreRuntimePlugin.getInstance().getDesignerCoreService();
      boolean deactive =
          designerCoreService != null
              ? Boolean.parseBoolean(
                  designerCoreService.getPreferenceStore(
                      ITalendCorePrefConstants.DEACTIVE_REPOSITORY_UPDATE))
              : true;
      if (deactive) { // disable to do update
        return false;
      }

      boolean propagated = RepositoryUpdateManager.openPropagationDialog();
      if (!propagated) {
        return false;
      }
    }

    boolean updated = false;
    for (IRepositoryUpdateManagerProvider provider : repositoryProviders) {
      // if one upate successfully, will return true.
      if (provider.updateForRepository(selection)) {
        updated = true;
      }
    }
    // Old Updates
    if (doOldUpdates(selection)) {
      updated = true;
    }
    if (!updated) {
      // nothing to update
      RepositoryUpdateManager.openNoModificationDialog();
    }
    return updated;
  }
  private void initProperty() {
    JobInfo jobInfo =
        new JobInfo(
            processItem,
            processItem.getProcess().getDefaultContext(),
            processItem.getProperty().getVersion());
    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    setProperty(PROJECT_ID, String.valueOf(currentProject.getEmfProject().getId()));
    setProperty(PROJECT_NAME, currentProject.getTechnicalLabel());

    String branchKey =
        IProxyRepositoryFactory.BRANCH_SELECTION
            + UNDER_LINE_CHAR
            + currentProject.getTechnicalLabel();
    Context ctx = CoreRuntimePlugin.getInstance().getContext();
    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
    if (rc.getFields().containsKey(branchKey) && rc.getFields().get(branchKey) != null) {
      String branchSelection = rc.getFields().get(branchKey);
      setProperty(BRANCH, branchSelection);
    }

    setProperty(JOB_ID, jobInfo.getJobId());
    setProperty(JOB_NAME, jobInfo.getJobName());
    String jobType = processItem.getProcess().getJobType();
    if (jobType == null) {
      /*
       * should call ConvertJobsUtil.getJobTypeFromFramework(processItem)
       *
       * ConvertJobsUtil.JobType.STANDARD.getDisplayName
       */
      jobType = "Standard"; // $NON-NLS-1$
    }
    setProperty(JOB_TYPE, jobType);
    setProperty(JOB_VERSION, jobInfo.getJobVersion());
    setProperty(CONTEXT_NAME, this.contextName);
    setProperty(DATE, DATAFORMAT.format(new Date()));

    setProperty(APPLY_CONTEXY_CHILDREN, String.valueOf(applyContextToChild));
    if (CommonsPlugin.isHeadless()) {
      setProperty(ADD_STATIC_CODE, String.valueOf(addStat));
    } else {
      setProperty(ADD_STATIC_CODE, Boolean.TRUE.toString()); // TDI-23641, in studio, false always.
    }
    setProperty(COMMANDLINE_VERSION, VersionUtils.getVersion());
  }
Esempio n. 8
0
  @Override
  public List<ModuleNeeded> getModulesNeededForJobs() throws PersistenceException {
    List<ModuleNeeded> importNeedsList = new ArrayList<ModuleNeeded>();
    IProxyRepositoryFactory repositoryFactory =
        CoreRuntimePlugin.getInstance().getRepositoryService().getProxyRepositoryFactory();
    ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
    if (jobType != null) {
      List<IRepositoryViewObject> jobs = repositoryFactory.getAll(jobType, true);
      for (IRepositoryViewObject cur : jobs) {
        if (!cur.isDeleted()) {
          ProcessItem item = (ProcessItem) cur.getProperty().getItem();
          if (item == null || item.getProcess() == null) {
            continue;
          }
          List<NodeType> nodes = item.getProcess().getNode();
          for (NodeType node : nodes) {
            List<ElementParameterType> elementParameter = node.getElementParameter();
            for (ElementParameterType elementParam : elementParameter) {
              if (elementParam.getField() != null
                  && elementParam.getField().equals(EParameterFieldType.MODULE_LIST.getName())) {
                String uniquename = coreSerivce.getParameterUNIQUENAME(node);
                ModuleNeeded toAdd =
                    new ModuleNeeded(
                        Messages.getString("AbstractEMFRepositoryFactory.job")
                            + item.getProperty().getLabel(), // $NON-NLS-1$
                        elementParam.getValue(),
                        Messages.getString("AbstractEMFRepositoryFactory.requiredComponent")
                            + uniquename
                            + ".",
                        true); //$NON-NLS-1$ //$NON-NLS-2$
                importNeedsList.add(toAdd);
              }
            }
          }
        }
      }
    }

    return importNeedsList;
  }
  /*
   * get valid the ContextItem.
   */
  public Set<ContextItem> getContextItems() {
    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    Set<ContextItem> itemList = null;

    try {
      itemList = new HashSet<ContextItem>(factory.getContextItem());
    } catch (PersistenceException e) {
      throw new RuntimeException(e);
    }
    // already did in AbstractRepositoryFactory.getContextItem()
    // if (itemList != null) {
    // List<ContextItem> toRemove = new ArrayList<ContextItem>();
    //
    // for (ContextItem contextItem : itemList) {
    // if (factory.getStatus(contextItem) == ERepositoryStatus.DELETED) {
    // toRemove.add(contextItem);
    // }
    // }
    // itemList.removeAll(toRemove);
    // }
    return itemList;
  }
  @SuppressWarnings("unchecked")
  private static String getDisplayValue(final IElementParameter param) {
    Object value = param.getValue();

    if (value instanceof String) {

      if (param.getName().equals("PROCESS_TYPE_VERSION")
          && value.equals(RelationshipItemBuilder.LATEST_VERSION)) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        return processItem.getProperty().getVersion();
      }
      if (param.getName().equals("PROCESS_TYPE_CONTEXT")) { // $NON-NLS-1$
        String jobId =
            (String)
                param
                    .getParentParameter()
                    .getChildParameters()
                    .get("PROCESS_TYPE_PROCESS")
                    .getValue(); //$NON-NLS-1$
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId);
        if (processItem == null) {
          return ""; //$NON-NLS-1$
        }
        // check if the selected context exists, if not, use the default context of the job.
        boolean contextExists = false;
        for (Object object : processItem.getProcess().getContext()) {
          if (object instanceof ContextType) {
            if (((ContextType) object).getName() != null
                && ((ContextType) object).getName().equals(value)) {
              contextExists = true;
              continue;
            }
          }
        }
        if (!contextExists) {
          return processItem.getProcess().getDefaultContext();
        }
        return (String) value;
      }
      // hywang add for 6484
      if ("SELECTED_FILE".equals(param.getRepositoryValue())) { // $NON-NLS-N$ //$NON-NLS-1$
        IElementParameter propertyParam =
            param
                .getElement()
                .getElementParameter(
                    "PROPERTY:REPOSITORY_PROPERTY_TYPE"); // $NON-NLS-N$ //$NON-NLS-1$
        if (propertyParam != null
            && propertyParam.getValue() != null
            && !propertyParam.getValue().equals("")) { // $NON-NLS-1$
          try {
            IRepositoryViewObject object =
                CoreRuntimePlugin.getInstance()
                    .getProxyRepositoryFactory()
                    .getLastVersion((String) propertyParam.getValue());
            if (object != null) {
              Item item = object.getProperty().getItem();
              String extension = null;

              String rule = ""; // $NON-NLS-1$
              String processLabelAndVersion = null;
              if (item instanceof RulesItem) {
                RulesItem rulesItem = (RulesItem) item;
                extension = rulesItem.getExtension();
                if (param.getElement() instanceof INode) {
                  INode node = (INode) param.getElement();
                  IProcess process = node.getProcess();
                  String jobLabel = process.getName();
                  String jobVersion = process.getVersion();
                  processLabelAndVersion =
                      JavaResourcesHelper.getJobFolderName(jobLabel, jobVersion);
                }

                rule =
                    "rules/final/"
                        + processLabelAndVersion
                        + "/"
                        + rulesItem.getProperty().getLabel() // $NON-NLS-1$ //$NON-NLS-2$
                        + rulesItem.getProperty().getVersion()
                        + extension;
              }
              return TalendQuoteUtils.addQuotes(rule);
            } else {
              return param.getValue().toString();
            }
          } catch (Exception e) {
            ExceptionHandler.process(e);
          }
        }
      }

      return (String) value;
    }
    if (param.getFieldType() == EParameterFieldType.RADIO
        || param.getFieldType() == EParameterFieldType.CHECK
        || param.getFieldType() == EParameterFieldType.AS400_CHECK) {
      if (value instanceof Boolean) {
        return ((Boolean) param.getValue()).toString();
      } else {
        return Boolean.FALSE.toString();
      }
    }

    if (param.getFieldType() == EParameterFieldType.TABLE) {
      List<Map<String, Object>> tableValues = (List<Map<String, Object>>) param.getValue();
      String[] items = param.getListItemsDisplayCodeName();
      String stringValues = "{"; // $NON-NLS-1$
      for (int i = 0; i < tableValues.size(); i++) {
        Map<String, Object> lineValues = tableValues.get(i);
        stringValues += "["; // $NON-NLS-1$
        for (int j = 0; j < items.length; j++) {

          Object currentValue = lineValues.get(items[j]);
          if (currentValue instanceof Integer) {
            IElementParameter tmpParam = (IElementParameter) param.getListItemsValue()[j];
            if (tmpParam.getListItemsDisplayName().length != 0) {
              stringValues += tmpParam.getListItemsDisplayName()[(Integer) currentValue];
            }
          } else {
            stringValues += currentValue;
          }

          if (j != (items.length - 1)) {
            stringValues += ","; // $NON-NLS-1$
          }
        }
        stringValues += "]"; // $NON-NLS-1$
        if (i != (tableValues.size() - 1)) {
          stringValues += ","; // $NON-NLS-1$
        }
      }
      stringValues += "}"; // $NON-NLS-1$
      return stringValues;
    }

    return new String(""); // $NON-NLS-1$
  }
Esempio n. 11
0
  public SalesforceSchemaWizard(
      IWorkbench workbench,
      boolean creation,
      RepositoryNode node,
      String[] existingNames,
      boolean isSinglePageOnly) {
    super(workbench, creation);
    this.existingNames = existingNames;
    this.isSinglePageOnly = isSinglePageOnly;
    setNeedsProgressMonitor(true);

    // TODO: should to changed icon.
    setDefaultPageImageDescriptor(ImageProvider.getImageDesc(ECoreImage.DEFAULT_WIZ));
    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case REPOSITORY_ELEMENT:
        pathToSave = RepositoryNodeUtilities.getPath(node);
        break;
      case SYSTEM_FOLDER:
        pathToSave = new Path(""); // $NON-NLS-1$
        break;
    }

    switch (node.getType()) {
      case SIMPLE_FOLDER:
      case SYSTEM_FOLDER:
        connection = ConnectionFactory.eINSTANCE.createSalesforceSchemaConnection();
        connection.setName(ERepositoryObjectType.METADATA_SALESFORCE_SCHEMA.getKey());
        MetadataTable metadataTable = ConnectionFactory.eINSTANCE.createMetadataTable();
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        metadataTable.setId(factory.getNextId());
        RecordFile record =
            (RecordFile)
                ConnectionHelper.getPackage(connection.getName(), connection, RecordFile.class);
        if (record != null) { // hywang
          PackageHelper.addMetadataTable(metadataTable, record);
        } else {
          RecordFile newrecord = RecordFactory.eINSTANCE.createRecordFile();
          newrecord.setName(connection.getName());
          ConnectionHelper.addPackage(newrecord, connection);
          PackageHelper.addMetadataTable(metadataTable, newrecord);
        }
        connectionProperty = PropertiesFactory.eINSTANCE.createProperty();
        connectionProperty.setAuthor(
            ((RepositoryContext)
                    CoreRuntimePlugin.getInstance()
                        .getContext()
                        .getProperty(Context.REPOSITORY_CONTEXT_KEY))
                .getUser());
        connectionProperty.setVersion(VersionUtils.DEFAULT_VERSION);
        connectionProperty.setStatusCode(""); // $NON-NLS-1$

        connectionItem = PropertiesFactory.eINSTANCE.createSalesforceSchemaConnectionItem();
        connectionItem.setProperty(connectionProperty);
        connectionItem.setConnection(connection);
        initProxySettings(connection);
        break;

      case REPOSITORY_ELEMENT:
        connection =
            (SalesforceSchemaConnection)
                ((ConnectionItem) node.getObject().getProperty().getItem()).getConnection();
        connectionProperty = node.getObject().getProperty();
        connectionItem = (ConnectionItem) node.getObject().getProperty().getItem();
        // set the repositoryObject, lock and set isRepositoryObjectEditable
        setRepositoryObject(node.getObject());
        isRepositoryObjectEditable();
        initLockStrategy();
        break;
    }
    if (!creation) {
      this.originaleObjectLabel = this.connectionItem.getProperty().getLabel();
      this.originalVersion = this.connectionItem.getProperty().getVersion();
      this.originalDescription = this.connectionItem.getProperty().getDescription();
      this.originalPurpose = this.connectionItem.getProperty().getPurpose();
      this.originalStatus = this.connectionItem.getProperty().getStatusCode();
    }
    initConnection();
  }
  public NexusServerBean getCustomNexusServer() {
    NexusServerBean serverBean = null;
    try {
      IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
      RepositoryContext repositoryContext = factory.getRepositoryContext();
      if (factory.isLocalConnectionProvider() || repositoryContext.isOffline()) {
        return null;
      }
      if (repositoryContext != null && repositoryContext.getFields() != null) {
        String adminUrl = repositoryContext.getFields().get(RepositoryConstants.REPOSITORY_URL);
        String userName = "";
        String password = "";
        User user = repositoryContext.getUser();
        if (user != null) {
          userName = user.getLogin();
          password = repositoryContext.getClearPassword();
        }

        if (adminUrl != null
            && !"".equals(adminUrl)
            && GlobalServiceRegister.getDefault().isServiceRegistered(IRemoteService.class)) {
          IRemoteService remoteService =
              (IRemoteService) GlobalServiceRegister.getDefault().getService(IRemoteService.class);
          JSONObject libServerObject;
          libServerObject = remoteService.getLibNexusServer(userName, password, adminUrl);
          if (libServerObject != null) {
            String nexus_url = libServerObject.getString(NexusServerUtils.KEY_NEXUS_RUL);
            String nexus_user = libServerObject.getString(NexusServerUtils.KEY_NEXUS_USER);
            String nexus_pass = libServerObject.getString(NexusServerUtils.KEY_NEXUS_PASS);
            String repositoryId =
                libServerObject.getString(NexusServerUtils.KEY_CUSTOM_LIB_REPOSITORY);

            // TODO check if custom nexus is valid , only check http response for now , need check
            // if it is
            // snapshot latter
            boolean connectionOk =
                NexusServerUtils.checkConnectionStatus(
                    nexus_url, repositoryId, nexus_user, nexus_pass);
            if (!connectionOk) {
              return null;
            }

            String newUrl = nexus_url;
            if (newUrl.endsWith(NexusConstants.SLASH)) {
              newUrl = newUrl.substring(0, newUrl.length() - 1);
            }
            if (nexus_user != null && !"".equals(nexus_user)) { // $NON-NLS-1$
              String[] split = newUrl.split("://"); // $NON-NLS-1$
              if (split.length != 2) {
                throw new RuntimeException(
                    "Nexus url is not valid ,please contract the administrator");
              }
              newUrl =
                  split[0]
                      + ":"
                      + nexus_user
                      + ":"
                      + nexus_pass
                      + "@//" //$NON-NLS-1$
                      + split[1];
            }
            newUrl =
                newUrl
                    + NexusConstants.CONTENT_REPOSITORIES
                    + repositoryId
                    + "@id="
                    + repositoryId; //$NON-NLS-1$

            serverBean = new NexusServerBean();
            serverBean.setServer(nexus_url);
            serverBean.setUserName(nexus_user);
            serverBean.setPassword(nexus_pass);
            serverBean.setRepositoryId(repositoryId);
            serverBean.setRepositoryUrl(newUrl);
          }
        }
      }
    } catch (Exception e) {
      serverBean = null;
      ExceptionHandler.process(e);
    }
    if (previousCustomBean == null && serverBean != null
        || previousCustomBean != null && !previousCustomBean.equals(serverBean)) {
      mavenResolver = null;
    }
    previousCustomBean = serverBean;
    return serverBean;
  }
/**
 * DOC chuger class global comment. Detailled comment <br>
 * $Id: XmlArray.java 38013 2010-03-05 14:21:59Z mhirt $
 */
public class XmlArray {

  private static final String TAG_ARRAY = "array"; // $NON-NLS-1$

  private static final String TAG_ROW = "row"; // $NON-NLS-1$

  private static final String TAG_FIELD = "field"; // $NON-NLS-1$

  private static int rowLimit =
      CoreRuntimePlugin.getInstance()
          .getCoreService()
          .getPreferenceStore()
          .getInt(ITalendCorePrefConstants.PREVIEW_LIMIT);;

  private List<XmlRow> rows;

  /**
   * Set the value of row limit back to default in preference.
   *
   * <p>yzhang Comment method "setLimitToDefault".
   */
  public static void setLimitToDefault() {
    XmlArray.rowLimit =
        CoreRuntimePlugin.getInstance()
            .getCoreService()
            .getPreferenceStore()
            .getInt(ITalendCorePrefConstants.PREVIEW_LIMIT);
  }

  /**
   * Sets the rowLimit.
   *
   * @param rowLimit the rowLimit to set
   */
  public static void setRowLimit(int limit) {
    if (limit < 0) {
      setLimitToDefault();
    } else {
      XmlArray.rowLimit = limit;
    }
  }

  /**
   * Getter for rowLimit.
   *
   * @return the rowLimit
   */
  public static int getRowLimit() {
    return rowLimit;
  }

  /** Constructs a new XmlArray. */
  private XmlArray() {
    super();

    rows = new ArrayList<XmlRow>();
  }

  /**
   * Getter for rows.
   *
   * @return the rows
   */
  public List<XmlRow> getRows() {
    return this.rows;
  }

  /**
   * Adds a row at the end of the array.
   *
   * @param row Row to add.
   */
  public void add(XmlRow row) {
    rows.add(row);
  }

  public static XmlArray createFrom(InputStream is)
      throws IOException, ParserConfigurationException, SAXException {
    XmlArray array = new XmlArray();

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(is);
    Node root = document.getFirstChild();
    if (!TAG_ARRAY.equals(root.getNodeName())) {
      throw new IOException(Messages.getString("XmlArray.InvalidFile")); // $NON-NLS-1$
    }

    // Rows
    NodeList rows = root.getChildNodes();
    int counter = 0;
    for (int r = 0; r < rows.getLength(); r++) {
      Node row = rows.item(r);
      if (TAG_ROW.equals(row.getNodeName())) {
        XmlRow xRow = new XmlRow();

        NodeList fields = row.getChildNodes();
        for (int f = 0; f < fields.getLength(); f++) {
          Node field = fields.item(f);
          if (TAG_FIELD.equals(field.getNodeName())) {
            XmlField xField = new XmlField(field.getTextContent());
            xRow.add(xField);
          }
        }

        array.add(xRow);
        counter++;
        if (counter >= rowLimit) {
          break;
        }
      }
    }

    return array;
  }
}
Esempio n. 14
0
 public IProxyRepositoryFactory getProxyRepositoryFactory() {
   IRepositoryService service = CoreRuntimePlugin.getInstance().getRepositoryService();
   return service.getProxyRepositoryFactory();
 }
  public AbstractScriptProjectSettingPage() {
    super();

    IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    readonly = factory.isUserReadOnlyOnCurrentProject();
  }
Esempio n. 16
0
 public RepositoryContext getRepositoryContext() {
   Context ctx = CoreRuntimePlugin.getInstance().getContext();
   return (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
 }