Java Code Examples for org.apache.sqoop.model.MLink#setLastUpdateUser()
The following examples show how to use
org.apache.sqoop.model.MLink#setLastUpdateUser() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LinkBean.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
private MLink restoreLink(Object obj) { JSONObject object = (JSONObject) obj; long connectorId = (Long) object.get(CONNECTOR_ID); JSONArray connectorLinkConfig = (JSONArray) object.get(LINK_CONFIG_VALUES); List<MConfig> linkConfig = restoreConfigList(connectorLinkConfig); MLink link = new MLink(connectorId, new MLinkConfig(linkConfig)); link.setPersistenceId((Long) object.get(ID)); link.setName((String) object.get(NAME)); link.setEnabled((Boolean) object.get(ENABLED)); link.setCreationUser((String) object.get(CREATION_USER)); link.setCreationDate(new Date((Long) object.get(CREATION_DATE))); link.setLastUpdateUser((String) object.get(UPDATE_USER)); link.setLastUpdateDate(new Date((Long) object.get(UPDATE_DATE))); return link; }
Example 2
Source File: BeanTestUtil.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
public static MLink createLink(String connectorName, String linkName, Long linkId, Date created, Date updated) { MLink link1 = getLink(connectorName); link1.setName(linkName); link1.setPersistenceId(linkId); link1.setCreationUser("admin"); link1.setCreationDate(created); link1.setLastUpdateUser("user"); link1.setLastUpdateDate(updated); link1.setEnabled(false); return link1; }
Example 3
Source File: CommonRepositoryHandler.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
private List<MLink> loadLinks(PreparedStatement stmt, Connection conn) throws SQLException { List<MLink> links = new ArrayList<MLink>(); ResultSet rsConnection = null; PreparedStatement connectorConfigFetchStatement = null; PreparedStatement connectorConfigInputStatement = null; try { rsConnection = stmt.executeQuery(); connectorConfigFetchStatement = conn.prepareStatement(crudQueries.getStmtSelectConfigForConfigurable()); connectorConfigInputStatement = conn.prepareStatement(crudQueries.getStmtFetchLinkInput()); while(rsConnection.next()) { long id = rsConnection.getLong(1); String name = rsConnection.getString(2); long connectorId = rsConnection.getLong(3); boolean enabled = rsConnection.getBoolean(4); String creationUser = rsConnection.getString(5); Date creationDate = rsConnection.getTimestamp(6); String updateUser = rsConnection.getString(7); Date lastUpdateDate = rsConnection.getTimestamp(8); connectorConfigFetchStatement.setLong(1, connectorId); connectorConfigInputStatement.setLong(1, id); connectorConfigInputStatement.setLong(3, id); List<MConfig> connectorLinkConfig = new ArrayList<MConfig>(); List<MConfig> fromConfig = new ArrayList<MConfig>(); List<MConfig> toConfig = new ArrayList<MConfig>(); loadConnectorConfigs(connectorLinkConfig, fromConfig, toConfig, connectorConfigFetchStatement, connectorConfigInputStatement, 2, conn); MLink link = new MLink(connectorId, new MLinkConfig(connectorLinkConfig)); link.setPersistenceId(id); link.setName(name); link.setCreationUser(creationUser); link.setCreationDate(creationDate); link.setLastUpdateUser(updateUser); link.setLastUpdateDate(lastUpdateDate); link.setEnabled(enabled); links.add(link); } } finally { closeResultSets(rsConnection); closeStatements(connectorConfigFetchStatement, connectorConfigInputStatement); } return links; }
Example 4
Source File: LinkRequestHandler.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
/** * Create or Update link in repository. * * @param ctx Context object * @return Validation bean object */ private JsonBean createUpdateLink(RequestContext ctx, boolean create) { Repository repository = RepositoryManager.getInstance().getRepository(); LinkBean linkBean = new LinkBean(); try { JSONObject postData = JSONUtils.parse(ctx.getRequest().getReader()); linkBean.restore(postData); } catch (IOException e) { throw new SqoopException(ServerError.SERVER_0003, "Can't read request content", e); } String username = ctx.getUserName(); // Get link object List<MLink> links = linkBean.getLinks(); if (links.size() != 1) { throw new SqoopException(ServerError.SERVER_0003, "Expected one link while parsing JSON request but got " + links.size()); } MLink postedLink = links.get(0); // Authorization check if (create) { AuthorizationEngine.createLink(String.valueOf(postedLink.getConnectorId())); } else { AuthorizationEngine.updateLink(String.valueOf(postedLink.getConnectorId()), String.valueOf(postedLink.getPersistenceId())); } MLinkConfig linkConfig = ConnectorManager.getInstance() .getConnectorConfigurable(postedLink.getConnectorId()).getLinkConfig(); if (!linkConfig.equals(postedLink.getConnectorLinkConfig())) { throw new SqoopException(ServerError.SERVER_0003, "Detected incorrect link config structure"); } // if update get the link id from the request URI if (!create) { String linkIdentifier = ctx.getLastURLElement(); // support linkName or linkId for the api long linkId = HandlerUtils.getLinkIdFromIdentifier(linkIdentifier, repository); if (postedLink.getPersistenceId() == MPersistableEntity.PERSISTANCE_ID_DEFAULT) { MLink existingLink = repository.findLink(linkId); postedLink.setPersistenceId(existingLink.getPersistenceId()); } } // Associated connector for this link SqoopConnector connector = ConnectorManager.getInstance().getSqoopConnector( postedLink.getConnectorId()); // Validate user supplied config data ConfigValidationResult connectorLinkConfigValidation = ConfigUtils.validateConfigs(postedLink .getConnectorLinkConfig().getConfigs(), connector.getLinkConfigurationClass()); // Return back link validation result bean ValidationResultBean linkValidationBean = new ValidationResultBean( connectorLinkConfigValidation); // If we're good enough let's perform the action if (connectorLinkConfigValidation.getStatus().canProceed()) { if (create) { AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(), "create", "link", String.valueOf(postedLink.getPersistenceId())); postedLink.setCreationUser(username); postedLink.setLastUpdateUser(username); repository.createLink(postedLink); linkValidationBean.setId(postedLink.getPersistenceId()); } else { AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(), "update", "link", String.valueOf(postedLink.getPersistenceId())); postedLink.setLastUpdateUser(username); repository.updateLink(postedLink); } } return linkValidationBean; }