Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
92bb7f4
Fix zero-size update bug
olsonanl Jul 21, 2015
fffc6e1
Rolling back makefile changes as they break deploy.
cshenry Jul 29, 2015
adfe706
Update and rename LICENSE to LICENSE.md
indiagordon Aug 3, 2015
2db2286
Minor tweaks to tests and script helper.
cshenry Aug 8, 2015
a87adfe
Merge branch 'master' of https://github.com/PATRIC3/Workspace
cshenry Aug 8, 2015
86ab16e
Merge branch 'master' of https://github.com/cshenry/Workspace
olsonanl Sep 2, 2015
4d00719
Implementing workspace publication
cshenry Dec 2, 2015
c611a7a
Fixing output for permission commands
cshenry Dec 2, 2015
83724b2
Fixing query formatting
cshenry Dec 2, 2015
c5c9c67
Fixing permission script
cshenry Dec 2, 2015
14d3319
Fixing query implementation on workspaces
cshenry Dec 2, 2015
22c4178
Debugging workspace query
cshenry Dec 2, 2015
2cd951c
Fixing query of workspaces
cshenry Dec 2, 2015
d247266
Fixing bug in workspace queries
cshenry Dec 2, 2015
4908884
Removing debug statement
cshenry Dec 2, 2015
3ecc604
Adding types, improving handling of folders, and removing probmodelse…
cshenry Jan 2, 2016
aa5e9a0
Fixing small bug in script helper
cshenry Jan 2, 2016
61ae2ab
Adding type
cshenry Jan 8, 2016
7ffbb34
Update .kbase_config when p3-login is run.
olsonanl Jan 29, 2016
378b679
Also update .kbase_config on p3-logout.
olsonanl Jan 29, 2016
a139a56
Remove debug
olsonanl Mar 9, 2016
d1d1895
Enabling access to public workspaces without auth
cshenry Mar 19, 2016
cc7faf9
Merge branch 'master' of https://github.com/PATRIC3/Workspace
olsonanl Mar 28, 2016
736089f
If we don't have a token, don't send auth header to shock. This looks…
olsonanl Mar 28, 2016
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
1 change: 0 additions & 1 deletion LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

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 service
all: bin compile-typespec 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: deploy-libs deploy-scripts
deploy-client: compile-typespec deploy-docs 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
12 changes: 6 additions & 6 deletions Workspace.spec
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ typedef structure {
bool metadata_only;
bool adminmode;
} get_params;
funcdef get(get_params input) returns (list<tuple<ObjectMeta,ObjectData>> output) authentication required;
funcdef get(get_params input) returns (list<tuple<ObjectMeta,ObjectData>> output) authentication optional;

/* "update_shock_meta" command
Description:
Expand Down Expand Up @@ -138,7 +138,7 @@ funcdef update_auto_meta(update_auto_meta_params input) returns (list<ObjectMeta
typedef structure {
list<FullObjectPath> objects;
} get_download_url_params;
funcdef get_download_url(get_download_url_params input) returns (list<string> urls) authentication required;
funcdef get_download_url(get_download_url_params input) returns (list<string> urls) authentication optional;

/* "get_archive_url" command
Description:
Expand All @@ -158,7 +158,7 @@ typedef structure {
string archive_name;
string archive_type;
} get_archive_url_params;
funcdef get_archive_url(get_archive_url_params input) returns (string url);
funcdef get_archive_url(get_archive_url_params input) returns (string url) authentication optional;

/* "list" command
Description:
Expand All @@ -182,7 +182,7 @@ typedef structure {
mapping<string,list<string>> query;
bool adminmode;
} list_params;
funcdef ls(list_params input) returns (mapping<FullObjectPath,list<ObjectMeta>> output) authentication required;
funcdef ls(list_params input) returns (mapping<FullObjectPath,list<ObjectMeta>> output) authentication optional;

/********** REORGANIZATION FUNCTIONS *******************/

Expand Down Expand Up @@ -244,7 +244,7 @@ typedef structure {
WorkspacePerm new_global_permission;
bool adminmode;
} set_permissions_params;
funcdef set_permissions(set_permissions_params input) returns (ObjectMeta output) authentication required;
funcdef set_permissions(set_permissions_params input) returns (list<tuple<Username,WorkspacePerm> > output) authentication required;

/* "list_permissions" command
Description:
Expand All @@ -258,6 +258,6 @@ typedef structure {
list<FullObjectPath> objects;
bool adminmode;
} list_permissions_params;
funcdef list_permissions(list_permissions_params input) returns (mapping<string,list<tuple<Username,WorkspacePerm> > > output) authentication required;
funcdef list_permissions(list_permissions_params input) returns (mapping<string,list<tuple<Username,WorkspacePerm> > > output) authentication optional;

};
60 changes: 54 additions & 6 deletions lib/Bio/P3/Workspace/ScriptHelpers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ use HTTP::Request::Common;
use LWP::UserAgent;
use Bio::P3::Workspace::WorkspaceClient;
use Bio::P3::Workspace::WorkspaceClientExt;
use Bio::ModelSEED::ProbModelSEED::ProbModelSEEDClient;

our $have_kb_auth = 0;
eval
{
require Bio::KBase::Auth;
$have_kb_auth = 1;
};

our $defaultWSURL = "http://p3.theseed.org/services/Workspace";
our $defaultAPPURL = "http://p3.theseed.org/services/app_service";
Expand Down Expand Up @@ -227,9 +233,12 @@ sub appurl {
sub process_paths {
my $paths = shift;
for (my $i=0; $i < @{$paths}; $i++) {
if ($paths->[$i] !~ /^\// && $paths->[$i] !~ /^PATRICSOLR/) {
if ($paths->[$i] !~ /^\// && $paths->[$i] !~ /^PATRIC:/ && $paths->[$i] !~ /^PUBSEED:/ && $paths->[$i] !~ /^RAST:/ && $paths->[$i] !~ /^REFSEQ:/) {
$paths->[$i] = Bio::P3::Workspace::ScriptHelpers::directory().$paths->[$i];
}
while ($paths->[$i] =~ m/[^\/]+\/\.\.\/*/) {
$paths->[$i] =~ s/[^\/]+\/\.\.\/*//g;
}
}
return $paths;
}
Expand Down Expand Up @@ -303,15 +312,33 @@ sub login {
user_id => $params->{user_id},
password => undef
});
#
# Update the KBase .kbase_config file as well.
#
if ($have_kb_auth)
{
Bio::KBase::Auth::SetConfigs(token => $token,
user_id => $params->{user_id},
password => undef);
}
}
return $token;
}

sub logout {
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => undef,
user_id => undef
Bio::P3::Workspace::ScriptHelpers::SetConfig({
token => undef,
user_id => undef
});
#
# Update the KBase .kbase_config file as well.
#
if ($have_kb_auth)
{
Bio::KBase::Auth::SetConfigs(token => undef,
user_id => undef,
password => undef);
}
}

sub msClient {
Expand All @@ -321,14 +348,35 @@ sub msClient {
}
if ($url eq "impl") {
require "Bio/ModelSEED/ProbModelSEED/ProbModelSEEDImpl.pm";
$ENV{KB_DEPLOYMENT_CONFIG} = "/Users/chenry/code/ProbModelSEED/configs/test.cfg";
$Bio::ModelSEED::ProbModelSEED::Service::CallContext = Bio::ModelSEED::ProbModelSEED::Service::CallContext->new(Bio::P3::Workspace::ScriptHelpers::token(),"unknown",Bio::P3::Workspace::ScriptHelpers::user());
my $client = Bio::ModelSEED::ProbModelSEED::ProbModelSEEDImpl->new();
return $client;
}
require "Bio/ModelSEED/ProbModelSEED/ProbModelSEEDClient.pm";
return Bio::ModelSEED::ProbModelSEED::ProbModelSEEDClient->new($url,token => Bio::P3::Workspace::ScriptHelpers::token());
}

sub get_workspace_object {
my $ref = shift;
my $options = shift;
my $input = {objects => [$ref]};
if ($options->{adminmode}) {
$input->{adminmode} = $options->{adminmode};
}
if ($options->{metadata_only}) {
$input->{metadata_only} = $options->{metadata_only};
}
my $wc = wsClient();
my $output = $wc->get($input);
if (defined($output->[0]->[11])) {
my $ua = LWP::UserAgent->new();
$ua->default_header( "Authorization" => $options->{token} );
my $res = $ua->get($options->{url});
$output->[1] = $res->{content};
}
return $output;
}

sub wsClient {
my $url = shift;
if (!defined($url)) {
Expand Down
30 changes: 24 additions & 6 deletions lib/Bio/P3/Workspace/Service.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Moose;
use POSIX;
use JSON;
use Bio::KBase::Log;
use Class::Load qw();
use Config::Simple;
my $get_time = sub { time, 0 };
eval {
Expand Down Expand Up @@ -44,15 +45,15 @@ our %return_counts = (
our %method_authentication = (
'create' => 'required',
'update_metadata' => 'required',
'get' => 'required',
'get' => 'optional',
'update_auto_meta' => 'required',
'get_download_url' => 'required',
'get_archive_url' => 'none',
'ls' => 'required',
'get_download_url' => 'optional',
'get_archive_url' => 'optional',
'ls' => 'optional',
'copy' => 'required',
'delete' => 'required',
'set_permissions' => 'required',
'list_permissions' => 'required',
'list_permissions' => 'optional',
);


Expand Down Expand Up @@ -149,6 +150,23 @@ sub _build_loggers
return $loggers;
}

#
# Override method from RPC::Any::Server::JSONRPC
# to eliminate the deprecation warning for Class::MOP::load_class.
#
sub _default_error {
my ($self, %params) = @_;
my $version = $self->default_version;
$version =~ s/\./_/g;
my $error_class = "JSON::RPC::Common::Procedure::Return::Version_${version}::Error";
Class::Load::load_class($error_class);
my $error = $error_class->new(%params);
my $return_class = "JSON::RPC::Common::Procedure::Return::Version_$version";
Class::Load::load_class($return_class);
return $return_class->new(error => $error);
}


#override of RPC::Any::Server
sub handle_error {
my ($self, $error) = @_;
Expand Down Expand Up @@ -396,7 +414,7 @@ sub get_method
"There is no method package named '$package'.");
}

Class::MOP::load_class($module);
Class::Load::load_class($module);
}

if (!$module->can($method)) {
Expand Down
62 changes: 11 additions & 51 deletions lib/Bio/P3/Workspace/WorkspaceClient.pm
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ sub new
{
my($class, $url, @args) = @_;

if (!defined($url))
{
$url = 'http://p3.theseed.org/services/Workspace';
}

my $self = {
client => Bio::P3::Workspace::WorkspaceClient::RpcClient->new,
Expand Down Expand Up @@ -511,7 +507,7 @@ sub get
{
my($self, @args) = @_;

# Authentication: required
# Authentication: optional

if ((my $n = @args) != 1)
{
Expand Down Expand Up @@ -733,7 +729,7 @@ sub get_download_url
{
my($self, @args) = @_;

# Authentication: required
# Authentication: optional

if ((my $n = @args) != 1)
{
Expand Down Expand Up @@ -828,7 +824,7 @@ sub get_archive_url
{
my($self, @args) = @_;

# Authentication: none
# Authentication: optional

if ((my $n = @args) != 1)
{
Expand Down Expand Up @@ -973,7 +969,7 @@ sub ls
{
my($self, @args) = @_;

# Authentication: required
# Authentication: optional

if ((my $n = @args) != 1)
{
Expand Down Expand Up @@ -1314,7 +1310,9 @@ sub delete

<pre>
$input is a set_permissions_params
$output is an ObjectMeta
$output is a reference to a list where each element is a reference to a list containing 2 items:
0: a Username
1: a WorkspacePerm
set_permissions_params is a reference to a hash where the following keys are defined:
path has a value which is a FullObjectPath
permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
Expand All @@ -1327,26 +1325,6 @@ FullObjectPath is a string
Username is a string
WorkspacePerm is a string
bool is an int
ObjectMeta is a reference to a list containing 12 items:
0: an ObjectName
1: an ObjectType
2: a FullObjectPath
3: (creation_time) a Timestamp
4: an ObjectID
5: (object_owner) a Username
6: an ObjectSize
7: a UserMetadata
8: an AutoMetadata
9: (user_permission) a WorkspacePerm
10: (global_permission) a WorkspacePerm
11: (shockurl) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string

</pre>

Expand All @@ -1355,7 +1333,9 @@ AutoMetadata is a reference to a hash where the key is a string and the value is
=begin text

$input is a set_permissions_params
$output is an ObjectMeta
$output is a reference to a list where each element is a reference to a list containing 2 items:
0: a Username
1: a WorkspacePerm
set_permissions_params is a reference to a hash where the following keys are defined:
path has a value which is a FullObjectPath
permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
Expand All @@ -1368,26 +1348,6 @@ FullObjectPath is a string
Username is a string
WorkspacePerm is a string
bool is an int
ObjectMeta is a reference to a list containing 12 items:
0: an ObjectName
1: an ObjectType
2: a FullObjectPath
3: (creation_time) a Timestamp
4: an ObjectID
5: (object_owner) a Username
6: an ObjectSize
7: a UserMetadata
8: an AutoMetadata
9: (user_permission) a WorkspacePerm
10: (global_permission) a WorkspacePerm
11: (shockurl) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string


=end text
Expand Down Expand Up @@ -1503,7 +1463,7 @@ sub list_permissions
{
my($self, @args) = @_;

# Authentication: required
# Authentication: optional

if ((my $n = @args) != 1)
{
Expand Down
Loading