diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..5889e7a85c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,21 @@ +.git +node-modules +__build__ +__server_build__ +typings +tsd_typings +npm-debug.log +dist +coverage +.idea +*.iml +*.ngfactory.ts +*.css.shim.ts +*.scss.shim.ts +.DS_Store +webpack.records.json +npm-debug.log.* +morgan.log +yarn-error.log +*.css +package-lock.json diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..f10164ebd0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +# This image will be published as dspace/dspace-angular +# See https://dspace-labs.github.io/DSpace-Docker-Images/ for usage details + +FROM node:8-alpine +WORKDIR /app +ADD . /app/ +EXPOSE 3000 + +RUN yarn install +CMD yarn run watch diff --git a/src/app/+item-page/field-components/collections/collections.component.spec.ts b/src/app/+item-page/field-components/collections/collections.component.spec.ts index 911a90175c..871018a9d8 100644 --- a/src/app/+item-page/field-components/collections/collections.component.spec.ts +++ b/src/app/+item-page/field-components/collections/collections.component.spec.ts @@ -60,7 +60,7 @@ describe('CollectionsComponent', () => { }); }); - describe('When the requested item request has succeeded', () => { + describe('When the requested item request has failed', () => { beforeEach(() => { collectionsComponent.item = failedMockItem; fixture.detectChanges(); diff --git a/src/app/core/cache/it-to-uuid-serializer.spec.ts b/src/app/core/cache/id-to-uuid-serializer.spec.ts similarity index 93% rename from src/app/core/cache/it-to-uuid-serializer.spec.ts rename to src/app/core/cache/id-to-uuid-serializer.spec.ts index 662d79cdce..e7f6929ddd 100644 --- a/src/app/core/cache/it-to-uuid-serializer.spec.ts +++ b/src/app/core/cache/id-to-uuid-serializer.spec.ts @@ -1,4 +1,4 @@ -import { IDToUUIDSerializer } from './it-to-uuid-serializer'; +import { IDToUUIDSerializer } from './id-to-uuid-serializer'; describe('IDToUUIDSerializer', () => { let serializer: IDToUUIDSerializer; diff --git a/src/app/core/cache/id-to-uuid-serializer.ts b/src/app/core/cache/id-to-uuid-serializer.ts new file mode 100644 index 0000000000..79576d448e --- /dev/null +++ b/src/app/core/cache/id-to-uuid-serializer.ts @@ -0,0 +1,35 @@ +import { hasValue } from '../../shared/empty.util'; + +/** + * Serializer to create unique fake UUID's from id's that might otherwise be the same across multiple object types + */ +export class IDToUUIDSerializer { + /** + * @param {string} prefix To prepend the original ID with + */ + constructor(private prefix: string) { + } + + /** + * Method to serialize a UUID + * @param {string} uuid + * @returns {any} undefined Fake UUID's should not be sent back to the server, but only be used in the UI + */ + Serialize(uuid: string): any { + return undefined; + } + + /** + * Method to deserialize a UUID + * @param {string} id Identifier to transform in to a UUID + * @returns {string} UUID based on the prefix and the given id + */ + Deserialize(id: string): string { + if (hasValue(id)) { + return `${this.prefix}-${id}`; + } else { + return id; + } + + } +} diff --git a/src/app/core/cache/it-to-uuid-serializer.ts b/src/app/core/cache/it-to-uuid-serializer.ts deleted file mode 100644 index 0d619f457b..0000000000 --- a/src/app/core/cache/it-to-uuid-serializer.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { hasValue } from '../../shared/empty.util'; - -export class IDToUUIDSerializer { - constructor(private prefix: string) { - } - - Serialize(uuid: string): any { - return undefined; // ui-only uuid doesn't need to be sent back to the server - } - - Deserialize(id: string): string { - if (hasValue(id)) { - return `${this.prefix}-${id}`; - } else { - return id; - } - - } -} diff --git a/src/app/core/cache/models/action-type.model.ts b/src/app/core/cache/models/action-type.model.ts new file mode 100644 index 0000000000..4965f93e89 --- /dev/null +++ b/src/app/core/cache/models/action-type.model.ts @@ -0,0 +1,64 @@ +/** + * Enum representing the Action Type of a Resource Policy + */ +export enum ActionType { + /** + * Action of reading, viewing or downloading something + */ + READ = 0, + + /** + * Action of modifying something + */ + WRITE = 1, + + /** + * Action of deleting something + */ + DELETE = 2, + + /** + * Action of adding something to a container + */ + ADD = 3, + + /** + * Action of removing something from a container + */ + REMOVE = 4, + + /** + * Action of performing workflow step 1 + */ + WORKFLOW_STEP_1 = 5, + + /** + * Action of performing workflow step 2 + */ + WORKFLOW_STEP_2 = 6, + + /** + * Action of performing workflow step 3 + */ + WORKFLOW_STEP_3 = 7, + + /** + * Action of performing a workflow abort + */ + WORKFLOW_ABORT = 8, + + /** + * Default Read policies for Bitstreams submitted to container + */ + DEFAULT_BITSTREAM_READ = 9, + + /** + * Default Read policies for Items submitted to container + */ + DEFAULT_ITEM_READ = 10, + + /** + * Administrative actions + */ + ADMIN = 11, +} diff --git a/src/app/core/cache/models/normalized-bitstream-format.model.ts b/src/app/core/cache/models/normalized-bitstream-format.model.ts index db9fa571f1..5d11c97107 100644 --- a/src/app/core/cache/models/normalized-bitstream-format.model.ts +++ b/src/app/core/cache/models/normalized-bitstream-format.model.ts @@ -2,34 +2,65 @@ import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize' import { BitstreamFormat } from '../../shared/bitstream-format.model'; import { mapsTo } from '../builders/build-decorators'; -import { IDToUUIDSerializer } from '../it-to-uuid-serializer'; +import { IDToUUIDSerializer } from '../id-to-uuid-serializer'; import { NormalizedObject } from './normalized-object.model'; +import { SupportLevel } from './support-level.model'; +/** + * Normalized model class for a Bitstream Format + */ @mapsTo(BitstreamFormat) @inheritSerialization(NormalizedObject) export class NormalizedBitstreamFormat extends NormalizedObject { + /** + * Short description of this Bitstream Format + */ @autoserialize shortDescription: string; + /** + * Description of this Bitstream Format + */ @autoserialize description: string; + /** + * String representing the MIME type of this Bitstream Format + */ @autoserialize mimetype: string; + /** + * The level of support the system offers for this Bitstream Format + */ @autoserialize - supportLevel: number; + supportLevel: SupportLevel; + /** + * True if the Bitstream Format is used to store system information, rather than the content of items in the system + */ @autoserialize internal: boolean; + /** + * String representing this Bitstream Format's file extension + */ @autoserialize extensions: string; + /** + * Identifier for this Bitstream Format + * Note that this ID is unique for bitstream formats, + * but might not be unique across different object types + */ @autoserialize id: string; + /** + * Universally unique identifier for this Bitstream Format + * Consist of a prefix and the id field to ensure the identifier is unique across all object types + */ @autoserializeAs(new IDToUUIDSerializer('bitstream-format'), 'id') uuid: string; } diff --git a/src/app/core/cache/models/normalized-bitstream.model.ts b/src/app/core/cache/models/normalized-bitstream.model.ts index db8002a874..63f84add41 100644 --- a/src/app/core/cache/models/normalized-bitstream.model.ts +++ b/src/app/core/cache/models/normalized-bitstream.model.ts @@ -5,6 +5,9 @@ import { Bitstream } from '../../shared/bitstream.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; +/** + * Normalized model class for a DSpace Bitstream + */ @mapsTo(Bitstream) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedBitstream extends NormalizedDSpaceObject { diff --git a/src/app/core/cache/models/normalized-bundle.model.ts b/src/app/core/cache/models/normalized-bundle.model.ts index 3b594dd308..5535ab57e5 100644 --- a/src/app/core/cache/models/normalized-bundle.model.ts +++ b/src/app/core/cache/models/normalized-bundle.model.ts @@ -5,6 +5,9 @@ import { Bundle } from '../../shared/bundle.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; +/** + * Normalized model class for a DSpace Bundle + */ @mapsTo(Bundle) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedBundle extends NormalizedDSpaceObject { @@ -25,6 +28,9 @@ export class NormalizedBundle extends NormalizedDSpaceObject { */ owner: string; + /** + * List of Bitstreams that are part of this Bundle + */ @autoserialize @relationship(ResourceType.Bitstream, true) bitstreams: string[]; diff --git a/src/app/core/cache/models/normalized-collection.model.ts b/src/app/core/cache/models/normalized-collection.model.ts index add0795ec5..a2c634c3e5 100644 --- a/src/app/core/cache/models/normalized-collection.model.ts +++ b/src/app/core/cache/models/normalized-collection.model.ts @@ -5,6 +5,9 @@ import { Collection } from '../../shared/collection.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; +/** + * Normalized model class for a DSpace Collection + */ @mapsTo(Collection) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedCollection extends NormalizedDSpaceObject { @@ -36,6 +39,9 @@ export class NormalizedCollection extends NormalizedDSpaceObject { @relationship(ResourceType.Community, false) owner: string; + /** + * List of Items that are part of (not necessarily owned by) this Collection + */ @autoserialize @relationship(ResourceType.Item, true) items: string[]; diff --git a/src/app/core/cache/models/normalized-community.model.ts b/src/app/core/cache/models/normalized-community.model.ts index 2ade808922..4ab2408a53 100644 --- a/src/app/core/cache/models/normalized-community.model.ts +++ b/src/app/core/cache/models/normalized-community.model.ts @@ -1,10 +1,13 @@ -import { autoserialize, inheritSerialization, autoserializeAs } from 'cerialize'; +import { autoserialize, inheritSerialization } from 'cerialize'; import { NormalizedDSpaceObject } from './normalized-dspace-object.model'; import { Community } from '../../shared/community.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; +/** + * Normalized model class for a DSpace Community + */ @mapsTo(Community) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedCommunity extends NormalizedDSpaceObject { @@ -36,6 +39,9 @@ export class NormalizedCommunity extends NormalizedDSpaceObject { @relationship(ResourceType.Community, false) owner: string; + /** + * List of Collections that are owned by this Community + */ @autoserialize @relationship(ResourceType.Collection, true) collections: string[]; diff --git a/src/app/core/cache/models/normalized-item.model.ts b/src/app/core/cache/models/normalized-item.model.ts index d6e9165471..7d518bd048 100644 --- a/src/app/core/cache/models/normalized-item.model.ts +++ b/src/app/core/cache/models/normalized-item.model.ts @@ -5,6 +5,9 @@ import { Item } from '../../shared/item.model'; import { mapsTo, relationship } from '../builders/build-decorators'; import { ResourceType } from '../../shared/resource-type'; +/** + * Normalized model class for a DSpace Item + */ @mapsTo(Item) @inheritSerialization(NormalizedDSpaceObject) export class NormalizedItem extends NormalizedDSpaceObject { @@ -53,6 +56,9 @@ export class NormalizedItem extends NormalizedDSpaceObject { @relationship(ResourceType.Collection, false) owningCollection: string; + /** + * List of Bitstreams that are owned by this Item + */ @autoserialize @relationship(ResourceType.Bitstream, true) bitstreams: string[]; diff --git a/src/app/core/cache/models/normalized-resource-policy.model.ts b/src/app/core/cache/models/normalized-resource-policy.model.ts index 3a874da46b..b767ca6491 100644 --- a/src/app/core/cache/models/normalized-resource-policy.model.ts +++ b/src/app/core/cache/models/normalized-resource-policy.model.ts @@ -1,23 +1,49 @@ import { autoserialize, autoserializeAs, inheritSerialization } from 'cerialize'; import { ResourcePolicy } from '../../shared/resource-policy.model'; -import { mapsTo } from '../builders/build-decorators'; -import { IDToUUIDSerializer } from '../it-to-uuid-serializer'; +import { mapsTo, relationship } from '../builders/build-decorators'; import { NormalizedObject } from './normalized-object.model'; +import { IDToUUIDSerializer } from '../id-to-uuid-serializer'; +import { ResourceType } from '../../shared/resource-type'; +import { ActionType } from './action-type.model'; +/** + * Normalized model class for a Resource Policy + */ @mapsTo(ResourcePolicy) @inheritSerialization(NormalizedObject) export class NormalizedResourcePolicy extends NormalizedObject { + /** + * The action that is allowed by this Resource Policy + */ + action: ActionType; + + /** + * The name for this Resource Policy + */ @autoserialize name: string; + /** + * The uuid of the Group this Resource Policy applies to + */ + @relationship(ResourceType.Group, false) @autoserializeAs(String, 'groupUUID') group: string; + /** + * Identifier for this Resource Policy + * Note that this ID is unique for resource policies, + * but might not be unique across different object types + */ @autoserialize id: string; + /** + * The universally unique identifier for this Resource Policy + * Consist of a prefix and the id field to ensure the identifier is unique across all object types + */ @autoserializeAs(new IDToUUIDSerializer('resource-policy'), 'id') uuid: string; } diff --git a/src/app/core/cache/models/support-level.model.ts b/src/app/core/cache/models/support-level.model.ts new file mode 100644 index 0000000000..30f759d55f --- /dev/null +++ b/src/app/core/cache/models/support-level.model.ts @@ -0,0 +1,19 @@ +/** + * Enum representing the Support Level of a Bitstream Format + */ +export enum SupportLevel { + /** + * Unknown for Bitstream Formats that are unknown to the system + */ + Unknown = 0, + + /** + * Unknown for Bitstream Formats that are known to the system, but not fully supported + */ + Known = 1, + + /** + * Supported for Bitstream Formats that are known to the system and fully supported + */ + Supported = 2, +} diff --git a/src/app/core/shared/bitstream-format.model.ts b/src/app/core/shared/bitstream-format.model.ts index 0089abce4a..9af345e607 100644 --- a/src/app/core/shared/bitstream-format.model.ts +++ b/src/app/core/shared/bitstream-format.model.ts @@ -2,24 +2,54 @@ import { CacheableObject } from '../cache/object-cache.reducer'; import { ResourceType } from './resource-type'; +/** + * Model class for a Bitstream Format + */ export class BitstreamFormat implements CacheableObject { + /** + * Short description of this Bitstream Format + */ shortDescription: string; + /** + * Description of this Bitstream Format + */ description: string; + /** + * String representing the MIME type of this Bitstream Format + */ mimetype: string; + /** + * The level of support the system offers for this Bitstream Format + */ supportLevel: number; + /** + * True if the Bitstream Format is used to store system information, rather than the content of items in the system + */ internal: boolean; + /** + * String representing this Bitstream Format's file extension + */ extensions: string; + /** + * The link to the rest endpoint where this Bitstream Format can be found + */ self: string; + /** + * A ResourceType representing the kind of Object of this BitstreamFormat + */ type: ResourceType; + /** + * Universally unique identifier for this Bitstream Format + */ uuid: string; } diff --git a/src/app/core/shared/resource-policy.model.ts b/src/app/core/shared/resource-policy.model.ts index 3bca324a47..cccbea1e89 100644 --- a/src/app/core/shared/resource-policy.model.ts +++ b/src/app/core/shared/resource-policy.model.ts @@ -1,20 +1,40 @@ - import { CacheableObject } from '../cache/object-cache.reducer'; import { ResourceType } from './resource-type'; +import { Group } from '../eperson/models/group.model'; +import { ActionType } from '../cache/models/action-type.model'; +/** + * Model class for a Resource Policy + */ export class ResourcePolicy implements CacheableObject { + /** + * The action that is allowed by this Resource Policy + */ + action: ActionType; - action: string; - + /** + * The name for this Resource Policy + */ name: string; - // TODO group should ofcourse become a group object - group: string; + /** + * The Group this Resource Policy applies to + */ + group: Group; + /** + * The link to the rest endpoint where this Resource Policy can be found + */ self: string; + /** + * A ResourceType representing the kind of Object of this ResourcePolicy + */ type: ResourceType; + /** + * The universally unique identifier for this Resource Policy + */ uuid: string; }