Skip to content

Commit

Permalink
Remove handlefilesetcommand()
Browse files Browse the repository at this point in the history
  • Loading branch information
TungYuChiang committed Jan 13, 2025
1 parent f62b3f6 commit 123fb1e
Showing 1 changed file with 1 addition and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,108 +356,7 @@ private void handleHelpCommand() {
Main.exit(-1);
}
}

/**
* Handles the command execution for filesets based on command type and the command line options.
*/
private void handleFilesetCommand() {
String url = getUrl();
String auth = getAuth();
String userName = line.getOptionValue(GravitinoOptions.LOGIN);
FullName name = new FullName(line);
String metalake = name.getMetalakeName();
String catalog = name.getCatalogName();
String schema = name.getSchemaName();

Command.setAuthenticationMode(auth, userName);

List<String> missingEntities = Lists.newArrayList();
if (catalog == null) missingEntities.add(CommandEntities.CATALOG);
if (schema == null) missingEntities.add(CommandEntities.SCHEMA);

// Handle CommandActions.LIST action separately as it doesn't require the `fileset`
if (CommandActions.LIST.equals(command)) {
checkEntities(missingEntities);
newListFilesets(url, ignore, metalake, catalog, schema).validate().handle();
return;
}

String fileset = name.getFilesetName();
if (fileset == null) missingEntities.add(CommandEntities.FILESET);
checkEntities(missingEntities);

switch (command) {
case CommandActions.DETAILS:
newFilesetDetails(url, ignore, metalake, catalog, schema, fileset).validate().handle();
break;

case CommandActions.CREATE:
{
String comment = line.getOptionValue(GravitinoOptions.COMMENT);
String[] properties = line.getOptionValues(CommandActions.PROPERTIES);
Map<String, String> propertyMap = new Properties().parse(properties);
newCreateFileset(url, ignore, metalake, catalog, schema, fileset, comment, propertyMap)
.validate()
.handle();
break;
}

case CommandActions.DELETE:
{
boolean force = line.hasOption(GravitinoOptions.FORCE);
newDeleteFileset(url, ignore, force, metalake, catalog, schema, fileset)
.validate()
.handle();
break;
}

case CommandActions.SET:
{
String property = line.getOptionValue(GravitinoOptions.PROPERTY);
String value = line.getOptionValue(GravitinoOptions.VALUE);
newSetFilesetProperty(url, ignore, metalake, catalog, schema, fileset, property, value)
.validate()
.handle();
break;
}

case CommandActions.REMOVE:
{
String property = line.getOptionValue(GravitinoOptions.PROPERTY);
newRemoveFilesetProperty(url, ignore, metalake, catalog, schema, fileset, property)
.validate()
.handle();
break;
}

case CommandActions.PROPERTIES:
newListFilesetProperties(url, ignore, metalake, catalog, schema, fileset)
.validate()
.handle();
break;

case CommandActions.UPDATE:
{
if (line.hasOption(GravitinoOptions.COMMENT)) {
String comment = line.getOptionValue(GravitinoOptions.COMMENT);
newUpdateFilesetComment(url, ignore, metalake, catalog, schema, fileset, comment)
.validate()
.handle();
}
if (line.hasOption(GravitinoOptions.RENAME)) {
String newName = line.getOptionValue(GravitinoOptions.RENAME);
newUpdateFilesetName(url, ignore, metalake, catalog, schema, fileset, newName)
.validate()
.handle();
}
break;
}

default:
System.err.println(ErrorMessages.UNSUPPORTED_ACTION);
break;
}
}


/**
* Retrieves the Gravitinno URL from the command line options or the GRAVITINO_URL environment
Expand Down

0 comments on commit 123fb1e

Please sign in to comment.