public RESTClient(LiferayConnectionProperties liferayConnectionProperties) { this( liferayConnectionProperties.endpoint.getValue(), liferayConnectionProperties); }
public LiferayInputReader( RuntimeContainer runtimeContainer, LiferaySource liferaySource, TLiferayInputProperties tLiferayInputProperties) { super(runtimeContainer, liferaySource); liferayConnectionResourceBaseProperties = tLiferayInputProperties; _queryCondition = tLiferayInputProperties.resource.condition.getValue(); }
public Schema getSchema() { return resource.main.schema.getValue(); }
@SuppressWarnings("unused") private List<String> _getSchemaFieldNames(Property<Schema> schemaProperty) { Schema schema = schemaProperty.getValue(); List<String> fieldNames = new ArrayList<>(); for (Schema.Field field : schema.getFields()) { fieldNames.add(field.name()); } return fieldNames; }
public String getEndpoint() { boolean forceHttps = _liferayConnectionProperties.forceHttps.getValue(); if (forceHttps) { return _replaceHttpSchemeWithHttps(_endpoint); } return _endpoint; }
public LiferayWriter( LiferayWriteOperation writeOperation, RuntimeContainer runtimeContainer, TLiferayOutputProperties tLiferayOutputProperties) { _liferayWriteOperation = writeOperation; _runtimeContainer = runtimeContainer; _tLiferayOutputProperties = tLiferayOutputProperties; _dieOnError = tLiferayOutputProperties.dieOnError.getValue(); _liferaySink = writeOperation.getSink(); _rejectWrites = new ArrayList<>(); _rejectSchema = TLiferayOutputProperties.createRejectSchema( tLiferayOutputProperties.resource.main.schema.getValue()); _successWrites = new ArrayList<>(); }
public void afterEndpoint() { webSiteProperty.setHost(endpoint.getValue()); }
private ClientConfig _getClientConfig() { ClientConfig clientConfig = _setCredentials(_userId, _password); clientConfig = clientConfig.property( ClientProperties.CONNECT_TIMEOUT, _liferayConnectionProperties.connectTimeout.getValue() * 1000); clientConfig = clientConfig.property( ClientProperties.READ_TIMEOUT, _liferayConnectionProperties.readTimeout.getValue() * 1000); return clientConfig; }
public void setupResourceURLPrefix() { LiferayConnectionProperties liferayConnectionProperties = getEffectiveLiferayConnectionProperties(); liferayConnectionProperties.webSiteProperty.setHost( liferayConnectionProperties.endpoint.getValue()); resourceProperty.setHost( liferayConnectionProperties.endpoint.getValue()); if (liferayConnectionProperties.siteFilter.getValue()) { resourceProperty.setUriPrefix( liferayConnectionProperties.webSiteProperty.getWebSiteURL()); return; } resourceProperty.setUriPrefix( liferayConnectionProperties.endpoint.getValue()); }
private void _updateOutputSchemas() { if (_log.isDebugEnabled()) { _log.debug("Update output schemas"); } Schema inputSchema = resource.main.schema.getValue(); schemaFlow.schema.setValue(inputSchema); Schema rejectSchema = createRejectSchema(inputSchema); schemaReject.schema.setValue(rejectSchema); }
/** * We have to reset the schema because of a Talend's internal * mechanism. @see https://github.com/Talend/tdi-studio-se/blob/737243fcdf1591970536d46edad98d2992b16593/main/plugins/org.talend.designer.core.generic/src/main/java/org/talend/designer/core/generic/model/GenericElementParameter.java#L319 * @review */ @Override public void afterSchema() { Schema schema = resource.main.schema.getValue(); if (_log.isTraceEnabled()) { _log.trace("Schema details:\n" + schema.toString()); DebugUtils.logCurrentStackTrace(_log); } if (schema.equals(SchemaProperties.EMPTY_SCHEMA)) { resource.main.schema.setValue(temporaryMainSchema); } }
public ValidationResult validateValidateCondition() { ValidationResultMutable validationResultMutable = new ValidationResultMutable(); validationResultMutable.setStatus(ValidationResult.Result.OK); LiferayConnectionProperties liferayConnectionProperties = getEffectiveLiferayConnectionProperties(); String endpointUrl = liferayConnectionProperties.endpoint.getValue(); try { URIUtils.addQueryConditionToURL(endpointUrl, condition.getValue()); } catch (Exception exception) { return ExceptionUtils.exceptionToValidationResult(exception); } return validationResultMutable; }
public void afterOperations() { if (_log.isDebugEnabled()) { Action action = operations.getValue(); _log.debug("Selected method: " + action.getMethodName()); } refreshLayout(getForm(Form.MAIN)); refreshLayout(getForm(Form.REFERENCE)); }
private Operation _getSupportedOperation( LiferaySourceOrSinkRuntime liferaySourceOrSinkRuntime) throws IOException, UnsupportedOperationException { List<Operation> supportedOperations = new ArrayList<>(); supportedOperations.addAll( liferaySourceOrSinkRuntime.getResourceSupportedOperations( resource.resourceProperty.getResourceURL())); Supplier<Stream<Operation>> operationStreamSupplier = () -> supportedOperations.stream(); final String availableOperations = _getAvailableOperations( operationStreamSupplier.get()); Action action = operations.getValue(); String method = action.getMethodName(); Stream<Operation> stream = operationStreamSupplier.get(); Operation supportedOperation = stream.filter( operation -> method.equals(operation.getMethod()) ).findFirst( ).orElseThrow( () -> new UnsupportedOperationException( i18nMessages.getMessage( "error.validation.operation", action.name(), availableOperations)) ); return supportedOperation; }
@Override public Schema getResourceSchemaByType(String resourceType) throws IOException { LiferayConnectionProperties liferayConnectionProperties = getEffectiveConnection(null); String endpointURL = liferayConnectionProperties.endpoint.getValue(); JsonNode apiDocumentationJsonNode = doApioGetRequest( endpointURL.concat("/doc")); ApioApiDocumentation apioApiDocumentation = new ApioApiDocumentation( apiDocumentationJsonNode); List<ApioApiDocumentation.SupportedClass> supportedClasses = apioApiDocumentation.getSupportedClasses(); Stream<ApioApiDocumentation.SupportedClass> supportedClassStream = supportedClasses.stream(); ApioApiDocumentation.SupportedClass resourceSupportedClass = supportedClassStream.filter( supportedClass -> resourceType.equals(supportedClass.getName()) ).findFirst( ).orElseThrow( () -> new IOException( String.format( "Unable to find '%s' type in the API Documentation", resourceType)) ); return ResourceCollectionSchemaInferrer.inferSchemaByResourceType( resourceSupportedClass); }
public RESTClient getRestClient(RuntimeContainer runtimeContainer) throws ApioException { LiferayConnectionProperties liferayConnectionProperties = getEffectiveConnection(runtimeContainer); if (restClient == null) { restClient = new RESTClient(liferayConnectionProperties); } else { String endpoint = restClient.getEndpoint(); if (!endpoint.equals( liferayConnectionProperties.endpoint.getValue())) { if (_log.isDebugEnabled()) { _log.debug( "Endpoint has been changed, initialize a new " + "RESTClient"); } restClient = new RESTClient(liferayConnectionProperties); return restClient; } } return restClient; }
private Response _handleResponse( String httpMethod, Invocation.Builder builder, Entity<String> entity) { boolean followRedirects = _liferayConnectionProperties.followRedirects.getValue(); Response response; if (entity == null) { if (followRedirects) { response = _follow3Redirects(builder.method(httpMethod)); } else { response = builder.method(httpMethod); } } else { if (followRedirects) { response = _follow3Redirects( builder.method(httpMethod, entity)); } else { response = builder.method(httpMethod, entity); } } return response; }
@Override public void refreshLayout(Form form) { super.refreshLayout(form); String referencedComponentId = getReferencedComponentId(); boolean useOtherConnection = false; if ((referencedComponentId != null) && referencedComponentId.startsWith( TLiferayConnectionDefinition.COMPONENT_NAME)) { useOtherConnection = true; } PropertiesUtils.setHidden(form, anonymousLogin, useOtherConnection); PropertiesUtils.setHidden(form, endpoint, useOtherConnection); PropertiesUtils.setHidden(form, loginType, useOtherConnection); PropertiesUtils.setHidden(form, password, useOtherConnection); PropertiesUtils.setHidden(form, siteFilter, useOtherConnection); PropertiesUtils.setHidden(form, userId, useOtherConnection); PropertiesUtils.setHidden(form, webSiteName, useOtherConnection); PropertiesUtils.setHidden(form, webSiteProperty, useOtherConnection); if (!useOtherConnection && anonymousLogin.getValue()) { PropertiesUtils.setHidden(form, userId, true); PropertiesUtils.setHidden(form, password, true); } if (!useOtherConnection && !siteFilter.getValue()) { PropertiesUtils.setHidden(form, webSiteName, true); PropertiesUtils.setHidden(form, webSiteProperty, true); } }
@Override public void setupProperties() { super.setupProperties(); endpoint.setValue(_HOST); followRedirects.setValue(true); forceHttps.setValue(false); loginType.setValue(LoginType.Basic); password.setValue(_PASSWORD); siteFilter.setValue(false); userId.setValue(_USER_ID); webSiteName.setValue(""); webSiteProperty.setHost(endpoint.getValue()); webSiteProperty.setValue(""); }