Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compile time syntax errors in ws-cp.pl #23

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ TPAGE_ARGS = --define kb_top=$(TARGET) \

TESTS = $(wildcard t/client-tests/*.t)

all: bin compile-typespec service
all: bin service

jarfile:
gen_java_client $(SERVER_SPEC) org.patricbrc.Workspace java
Expand Down Expand Up @@ -84,7 +84,7 @@ bin: $(BIN_PERL) $(BIN_SERVICE_PERL)

deploy: deploy-client deploy-service
deploy-all: deploy-client deploy-service
deploy-client: compile-typespec deploy-docs deploy-libs deploy-scripts
deploy-client: deploy-libs deploy-scripts

deploy-service: deploy-dir deploy-monit deploy-libs deploy-service-scripts
$(TPAGE) $(TPAGE_ARGS) service/start_service.tt > $(TARGET)/services/$(SERVICE)/start_service
Expand Down
22 changes: 13 additions & 9 deletions lib/Bio/P3/Workspace/ScriptHelpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,12 @@ sub login {
my $ua = LWP::UserAgent->new();
my $res = $ua->post($url,$content);
if (!$res->is_success) {
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => undef,
user_id => undef
});
if (!defined($params->{tokenonly}) || $params->{tokenonly} == 0) {
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => undef,
user_id => undef
});
}
return undef;
}
my $token;
Expand All @@ -295,11 +297,13 @@ sub login {
my $data = decode_json $res->content;
$token = $data->{token};
}
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => $token,
user_id => $params->{user_id},
password => undef
});
if (!defined($params->{tokenonly}) || $params->{tokenonly} == 0) {
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => $token,
user_id => $params->{user_id},
password => undef
});
}
return $token;
}

Expand Down
13 changes: 12 additions & 1 deletion lib/Bio/P3/Workspace/WorkspaceImpl.pm
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,6 @@ sub _validate_save_objects_before_saving {
}
} elsif ($user ne $self->_getUsername() && $self->_adminmode() == 0) {
#Users can only create their own workspaces
print STDERR "user=$user username=" . $self->_getUsername() . "\n";
$self->_error("Insufficient permissions to create ".$objects->[$i]->[0]);
} elsif ($objects->[$i]->[1] ne "folder") {
#Workspace must be a folder
Expand Down Expand Up @@ -711,13 +710,19 @@ sub _delete_validated_object_set {
#Delete the specified workspace and all the objects it contains**
sub _delete_workspace {
my ($self,$wsobj) = @_;
if (!defined($wsobj->{owner}) || length($wsobj->{owner}) == 0) {$self->_error("Owner not specified in deletion!");}
if (!defined($wsobj->{name}) || length($wsobj->{name}) == 0) {$self->_error("Top directory not specified in deletion!");}
rmtree($self->_db_path()."/".$wsobj->{owner}."/".$wsobj->{name});
$self->_mongodb()->get_collection('workspaces')->remove({uuid => $wsobj->{uuid}});
$self->_mongodb()->get_collection('objects')->remove({workspace_uuid => $wsobj->{uuid}});
}
#Delete the specified object**
sub _delete_object {
my ($self,$obj,$nodeletefiles) = @_;
#Ensuring all parts of object path have nonzero length
if (!defined($obj->{wsobj}->{owner}) || length($obj->{wsobj}->{owner}) == 0) {$self->_error("Owner not specified in deletion!");}
if (!defined($obj->{wsobj}->{name}) || length($obj->{wsobj}->{name}) == 0) {$self->_error("Top directory not specified in deletion!");}
if (!defined($obj->{name}) || length($obj->{name}) == 0) {$self->_error("Name not specified in deletion!");}
if ($obj->{folder} == 1) {
my $objs = $self->_get_directory_contents($obj,0);
for (my $i=0; $i < @{$objs}; $i++) {
Expand Down Expand Up @@ -800,6 +805,8 @@ sub _create {
#This function creates workspaces**
sub _create_workspace {
my ($self,$specs) = @_;
if (!defined($specs->{user}) || length($specs->{user}) == 0) {$self->_error("Owner not specified in creation!");}
if (!defined($specs->{workspace}) || length($specs->{workspace}) == 0) {$self->_error("Top directory not specified in creation!");}
#Creating workspace directory on disk
File::Path::mkpath ($self->_db_path()."/".$specs->{user}."/".$specs->{workspace});
#Creating workspace object in mongodb
Expand Down Expand Up @@ -829,6 +836,7 @@ sub _create_object {
my ($self,$specs) = @_;
$specs->{path} =~ s/^\/+//;
$specs->{path} =~ s/\/+$//;

my $uuid = Data::UUID->new()->create_str();
if (defined($specs->{move}) && $specs->{move} == 1) {
$uuid = $specs->{data}->{uuid};
Expand All @@ -855,6 +863,9 @@ sub _create_object {
if (!-e $self->{_params}->{"script-path"}."/ws-autometa-".$specs->{type}.".pl") {
$object->{autometadata} = {};
}
if (!defined($object->{wsobj}->{owner}) || length($object->{wsobj}->{owner}) == 0) {$self->_error("Owner not specified in creation!");}
if (!defined($object->{wsobj}->{name}) || length($object->{wsobj}->{name}) == 0) {$self->_error("Top directory not specified in creation!");}
if (!defined($object->{name}) || length($object->{name}) == 0) {$self->_error("Name not specified in creation!");}
if ($specs->{type} eq "folder") {
#Creating folder on file system
$object->{autometadata} = {};
Expand Down
Loading